【花雕动手做】有趣好玩的音乐可视化(23)--3合1闪点光纤

2022-09-171.5万
AI 快速预览详细 收起
本文介绍了使用闪点光纤(打点水帘光纤)进行音乐可视化的实验。作者从最简单的开始,逐步尝试各种方案,积累了有用的音乐频谱可视化资料。文中详细描述了闪点光纤的使用方法,并展示了实验结果。适合零基础的新手和对音乐可视化感兴趣的用户。
偶然心血来潮,想要做一个音乐可视化的系列专题。这个专题的难度有点高,涉及面也比较广泛,相关的FFT和FHT等算法也相当复杂,不过还是打算从最简单的开始,实际动手做做试验,耐心尝试一下各种方案,逐步积累些有用的音乐频谱可视化的资料,也会争取成型一些实用好玩的音乐可视器项目。

前面已经尝试了二种光导纤维,这次我找到了一个新的品种,叫闪点光纤(也称为打点水帘光纤),包括直径1mm的四十米,3合1 的十米(单根直径也是1mm)。

【花雕动手做】有趣好玩的音乐可视化(23)--3合1闪点光纤图1

创作许可协议

本项目采用 None(不开放任何权利,保留所有权利) 进行许可。

评论(31)
驴友花雕
驴友花雕
作者
【花雕动手做】看见声音,基于Arduino系列音乐可视器(1)---LED节奏灯
https://mc.dfrobot.com.cn/thread-311167-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(2)---OLED频谱灯
https://mc.dfrobot.com.cn/thread-311174-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(3)---RGB律动灯
https://mc.dfrobot.com.cn/thread-311183-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(4)---WS2812条灯
https://mc.dfrobot.com.cn/thread-311190-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(5)---WS2812柱跳灯
https://mc.dfrobot.com.cn/thread-311192-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(6)---点阵频谱灯
https://mc.dfrobot.com.cn/thread-311201-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(7)---大方格频谱灯
https://mc.dfrobot.com.cn/thread-311364-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(8)---四位32段点阵屏
https://mc.dfrobot.com.cn/thread-311490-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(9)---X Music Spectrum
https://mc.dfrobot.com.cn/thread-311627-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(10)---WS2812硬板屏
https://mc.dfrobot.com.cn/thread-311641-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(11)---WS2812幻彩灯带
https://mc.dfrobot.com.cn/thread-313648-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(12)---米管快速节奏灯
https://mc.dfrobot.com.cn/thread-313708-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(13)---有机棒立柱灯
https://mc.dfrobot.com.cn/thread-313723-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(14)---水杯水瓶灯
https://mc.dfrobot.com.cn/thread-313803-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(15)--横排LED方管灯
https://mc.dfrobot.com.cn/thread-313811-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(16)--热干胶棒棒灯
https://mc.dfrobot.com.cn/thread-313844-1-1.html
【花雕动手做】有趣好玩音乐可视化系列(17)--光导纤维灯
https://mc.dfrobot.com.cn/thread-313867-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(18)--LED平面板灯
https://mc.dfrobot.com.cn/thread-313951-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(19)--通体光纤灯
https://mc.dfrobot.com.cn/thread-313962-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(20)--首饰盒镜子灯
https://mc.dfrobot.com.cn/thread-313969-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(21)--CD 光盘灯
https://mc.dfrobot.com.cn/thread-313984-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(22)--LED无限魔方
https://mc.dfrobot.com.cn/thread-313994-1-1.html
【花雕动手做】有趣好玩的音乐可视化(23)--3合1闪点光纤
https://mc.dfrobot.com.cn/thread-314168-1-1.html
【花雕动手做】有趣好玩的音乐可视化(24)--无限LED镜子灯
https://mc.dfrobot.com.cn/thread-314180-1-1.html
【花雕动手做】有趣好玩音乐可视化(25)--水龙卷旋涡灯
https://mc.dfrobot.com.cn/thread-314231-1-1.html
【花雕动手做】有趣好玩音乐可视化系列(26)--LED 超立方体
https://mc.dfrobot.com.cn/thread-314244-1-1.html
【花雕动手做】有趣好玩的音乐可视化(27)--磁搅LED水旋灯
https://mc.dfrobot.com.cn/thread-314273-1-1.html
驴友花雕
驴友花雕
作者
实验场景图

驴友花雕
驴友花雕
作者
实验的视频记录(4分40秒)
https://v.youku.com/v_show/id_XNTkwNDI3MTk4NA==.html?spm=a2hcb.playlsit.page.1
[media=x,500,375]https://v.youku.com/v_show/id_XNTkwNDI3MTk4NA==.html?spm=a2hcb.playlsit.page.1[/media]
驴友花雕
驴友花雕
作者
[backcolor=rgb(255, 255, 255)][font=Consolas, "][color=#95a5a6] 【花雕动手做】有趣好玩的音乐可视化系列小项目(23)--3合1闪点光纤灯
实验程序五:Adafruit_NeoPixel音乐反应式LED灯


[code] 【花雕动手做】有趣好玩的音乐可视化系列小项目(23)--3合1闪点光纤灯
实验程序五:Adafruit_NeoPixel音乐反应式LED灯
*/
#include
#include
#include
#define N_PIXELS 60
#define MIC_PIN A0
#define LED_PIN 6
#define NOISE 10
#define TOP (N_PIXELS+2)
#define LED_TYPE WS2811
#define BRIGHTNESS 10
#define COLOR_ORDER GRB
CRGB leds[N_PIXELS];
int lvl = 0, minLvl = 0, maxLvl = 10;
ExponentialFilter ADCFilter(5, 0);
void setup() {
FastLED.addLeds(leds, N_PIXELS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
int n, height;
n = analogRead(MIC_PIN);
n = abs(1023 - n);
n = (n <= NOISE) ? 0 : abs(n - NOISE);
ADCFilter.Filter(n);
lvl = ADCFilter.Current();
// Serial.print(n);
// Serial.print(" ");
// Serial.println(lvl);
height = TOP * (lvl - minLvl) / (long)(maxLvl - minLvl);
if (height < 0L) height = 0;
else if (height > TOP) height = TOP;
for (uint8_t i = 0; i < N_PIXELS; i++) {
if (i >= height) leds[i] = CRGB(0, 0, 0);
else leds[i] = Wheel( map( i, 0, N_PIXELS - 1, 30, 150 ) );
}
FastLED.show();
}
CRGB Wheel(byte WheelPos) {
if (WheelPos < 85)
return CRGB(WheelPos * 3, 255 - WheelPos * 3, 0);
else if (WheelPos < 170) {
WheelPos -= 85;
return CRGB(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return CRGB(0, WheelPos * 3, 255 - WheelPos * 3);
}
}[/code]
[/font][/backcolor][/color]
驴友花雕
驴友花雕
作者
实验的视频记录
https://v.youku.com/v_show/id_XNTkwMjczNTA3Mg==.html?spm=a2hcb.playlsit.page.3
[media=x,500,375]https://v.youku.com/v_show/id_XNTkwMjczNTA3Mg==.html?spm=a2hcb.playlsit.page.3[/media]
驴友花雕
驴友花雕
作者
实验场景图 动态图

驴友花雕
驴友花雕
作者
[backcolor=rgb(255, 255, 255)][font=Consolas, "][color=#95a5a6] 【花雕动手做】有趣好玩的音乐可视化系列小项目(23)--3合1闪点光纤灯[/font][/backcolor][/color]
[backcolor=rgb(255, 255, 255)][font=Consolas, "][color=#95a5a6] 项目程序之四:NeoPixel 测试程序[/font][/backcolor][/color]
[backcolor=rgb(255, 255, 255)][font=Consolas, "][color=#95a5a6]
[/font][/backcolor][/color]
[backcolor=rgb(255, 255, 255)][font=Consolas, "][code]/*
【花雕动手做】有趣好玩的音乐可视化系列小项目(23)--3合1闪点光纤灯
项目程序之四:NeoPixel 测试程序
*/
#include
#ifdef __AVR__
#include // Required for 16 MHz Adafruit Trinket
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN 6
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 24
// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
// setup() function -- runs once at startup --------------------------------
void setup() {
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(250); // Set BRIGHTNESS to about 1/5 (max = 255)
}
// loop() function -- runs repeatedly as long as board is on ---------------
void loop() {
// Fill along the length of the strip in various colors...
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color( 0, 255, 0), 50); // Green
colorWipe(strip.Color( 0, 0, 255), 50); // Blue
// Do a theater marquee effect in various colors...
theaterChase(strip.Color(127, 127, 127), 50); // White, half brightness
theaterChase(strip.Color(127, 0, 0), 50); // Red, half brightness
theaterChase(strip.Color( 0, 0, 127), 50); // Blue, half brightness
rainbow(10); // Flowing rainbow cycle along the whole strip
theaterChaseRainbow(50); // Rainbow-enhanced theaterChase variant
}
// Some functions of our own for creating animated effects -----------------
// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single 'packed' 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
strip.setPixelColor(i, color); // Set pixel's color (in RAM)
strip.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}
// Theater-marquee-style chasing lights. Pass in a color (32-bit value,
// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms)
// between frames.
void theaterChase(uint32_t color, int wait) {
for (int a = 0; a < 10; a++) { // Repeat 10 times...
for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2...
strip.clear(); // Set all pixels in RAM to 0 (off)
// 'c' counts up from 'b' to end of strip in steps of 3...
for (int c = b; c < strip.numPixels(); c += 3) {
strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
}
strip.show(); // Update strip with new contents
delay(wait); // Pause for a moment
}
}
}
// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
void rainbow(int wait) {
// Hue of first pixel runs 5 complete loops through the color wheel.
// Color wheel has a range of 65536 but it's OK if we roll over, so
// just count from 0 to 5*65536. Adding 256 to firstPixelHue each time
// means we'll make 5*65536/256 = 1280 passes through this outer loop:
for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) {
for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
// Offset pixel hue by an amount to make one full revolution of the
// color wheel (range of 65536) along the length of the strip
// (strip.numPixels() steps):
int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
// strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or
// optionally add saturation and value (brightness) (each 0 to 255).
// Here we're using just the single-argument hue variant. The result
// is passed through strip.gamma32() to provide 'truer' colors
// before assigning to each pixel:
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
}
strip.show(); // Update strip with new contents
delay(wait); // Pause for a moment
}
}
// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames.
void theaterChaseRainbow(int wait) {
int firstPixelHue = 0; // First pixel starts at red (hue 0)
for (int a = 0; a < 30; a++) { // Repeat 30 times...
for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2...
strip.clear(); // Set all pixels in RAM to 0 (off)
// 'c' counts up from 'b' to end of strip in increments of 3...
for (int c = b; c < strip.numPixels(); c += 3) {
// hue of pixel 'c' is offset by an amount to make one full
// revolution of the color wheel (range 65536) along the length
// of the strip (strip.numPixels() steps):
int hue = firstPixelHue + c * 65536L / strip.numPixels();
uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB
strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
}
strip.show(); // Update strip with new contents
delay(wait); // Pause for a moment
firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
}
}
}[/code]
[/font][/backcolor]

驴友花雕
驴友花雕
作者
实验的视频记录
https://v.youku.com/v_show/id_XNTkwMzk2MTExMg==.html?spm=a2hcb.playlsit.page.1
[media=x,500,375]https://v.youku.com/v_show/id_XNTkwMzk2MTExMg==.html?spm=a2hcb.playlsit.page.1[/media]
驴友花雕
驴友花雕
作者
【花雕动手做】有趣好玩的音乐可视化系列小项目(23)--3合1闪点光纤灯
项目程序之三:FastLED音乐反应节奏灯
模块接线:WS2812B接D6
MAX4466 UNO
VCC 5V
GND GND
OUT D7
[code]/*
【花雕动手做】有趣好玩的音乐可视化系列小项目(23)--3合1闪点光纤灯
项目程序之三:FastLED音乐反应节奏灯
模块接线:WS2812B接D6
MAX4466 UNO
VCC 5V
GND GND
OUT D7
*/
#include
#define LED_PIN 6
#define NUM_LEDS 24
CRGB leds[NUM_LEDS];
uint8_t hue = 0;
int soundsensor = A0;
void setup() {
delay(3000);
FastLED.setBrightness(255);
pinMode(soundsensor, INPUT);
FastLED.addLeds(leds, NUM_LEDS);
}
void loop() {
int sensval = digitalRead(soundsensor);
if (sensval == 1) {
leds[0] = CRGB :: Red;
fill_solid(leds, NUM_LEDS, CRGB :: Blue);
rainbow_moving();
FastLED.show();
delay(100);
}
else {
leds[0] = CRGB :: Black;
fill_solid(leds, NUM_LEDS, CRGB :: Black);
FastLED.show();
delay(100);
}
}
void rainbow_moving() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(hue + (i * 10), 255, 255);
}
EVERY_N_MILLISECONDS(10) {
hue++;
}
}[/code]
驴友花雕
驴友花雕
作者
实验的视频记录
https://v.youku.com/v_show/id_XNTkwMjU0NDc0NA==.html?spm=a2hcb.playlsit.page.1
[media=x,500,375]https://v.youku.com/v_show/id_XNTkwMjU0NDc0NA==.html?spm=a2hcb.playlsit.page.1[/media]
驴友花雕
驴友花雕
作者
实验场景图

驴友花雕
驴友花雕
作者
【花雕动手做】有趣好玩的音乐可视化系列小项目(23)--3合1闪点光纤灯
项目程序之二:闪点光纤灯简易流动变色测试
模块接线:WS2812B接D6
MAX4466 UNO
VCC 5V
GND GND
OUT D7
[code]/*
【花雕动手做】有趣好玩的音乐可视化系列小项目(23)--3合1闪点光纤灯
项目程序之二:闪点光纤灯简易流动变色测试
模块接线:WS2812B接D6
MAX4466 UNO
VCC 5V
GND GND
OUT D7
*/
#include
#define LED_PIN 6
#define NUM_LEDS 24
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds(leds, NUM_LEDS);
}
void loop() {
for (int i = 0; i <= 23; i++) {
leds[i] = CRGB ( 0, 0, 255);
FastLED.show();
delay(200);
}
for (int i = 23; i >= 0; i--) {
leds[i] = CRGB ( 255, 0, 0);
FastLED.show();
delay(200);
}
for (int i = 0; i <= 23; i++) {
leds[i] = CRGB ( 0, 255, 0);
FastLED.show();
delay(200);
}
}[/code]
驴友花雕
驴友花雕
作者
实验场景图

驴友花雕
驴友花雕
作者
实验场景图 动态图

驴友花雕
驴友花雕
作者
【花雕动手做】有趣好玩的音乐可视化系列小项目(23)--3合1闪点光纤灯
项目程序之一:绿色单灯循环测试
模块接线:WS2812B接D6
MAX4466 UNO
VCC 5V
GND GND
OUT D7
[code]/*
【花雕动手做】有趣好玩的音乐可视化系列小项目(23)--3合1闪点光纤灯
项目程序之一:绿色单灯循环测试
模块接线:WS2812B接D6
MAX4466 UNO
VCC 5V
GND GND
OUT D7
*/
#include
#define PIN 6
#define MAX_LED 24
#define ADD true
#define SUB false
int val = 0;
boolean stat = ADD;
Adafruit_NeoPixel strip = Adafruit_NeoPixel( MAX_LED, PIN, NEO_RGB + NEO_KHZ800 );
void setup() {
strip.begin();
strip.show();
}
void loop() {
uint8_t i, a = 0;
uint32_t color = strip.Color(255, 100, 0);
while (a < 25)
{
for (i = 0; i < 24; i++)
{
if (i == a) strip.setPixelColor(i, color);
else strip.setPixelColor(i, 0);
}
strip.show();
delay(200);
a++;
}
}[/code]
驴友花雕
驴友花雕
作者
闪点光纤灯基本成型了

驴友花雕
驴友花雕
作者
闪点光纤灯基本成型了

驴友花雕
驴友花雕
作者
光纤束捆

驴友花雕
驴友花雕
作者
三合一闪点光纤10米的切段

驴友花雕
驴友花雕
作者
1mm闪点光纤40米切段