Using USB to send sound signals

This is going to be my first post on here so please let me know if i'm doing something wrong.

I want to make a reactive LED strip. I'm using a ws2812b led strip and i have it mounted behind my monitors. I have messed around with some standard light shows but now i want to make it reactive to sound. There is a catch though. I want it to receive the sound signal over USB and not by using a microphone wired up to the arduino. The board i'm using is an UNO.

I have done some googling, but i can't find any useful info. Does anyone here have any knowledge if i can even do this?

Thanks for any help!

Best regards
/David

Do the sound processing on the part of your kit that can handle it (i.e. your PC), send the results over the USB to the Arduino, and have it control the LEDs based on those commands.

What will you use for software on the PC?

Using USB to send sound signals

Without going into all of the "difficulties", I'll just say, that's probably impossible with that the same time Arduino. Plus, the computer would have to send digital audio to the Arduino plus a soundcard and without special software or drivers the computer can only use one "soundcard" at a time...

...but now i want to make it reactive to sound. There is a catch though. I want it to receive the sound signal over USB and not by using a microphone wired up to the arduino.

It's fairly common to send a line-level (or headphone level) signal to the Arduino, and you can easily "split" the signal, sending it to your amp and the Arduino at the same time.

Just to get you started take a look at my [u]World's Simplest Lighting Effect[/u]. ...It's a pretty boring "flicker" effect so it's mostly just an example but there is a schematic showing how to bias the input so it can read the negative-half of the AC audio signal.

USB can be useful if you have a "programmed show" with the same-exact music and same-exact lighting every night. But if you want it to "react", an analog audio signal is the way to go.

wvmarle:
Do the sound processing on the part of your kit that can handle it (i.e. your PC), send the results over the USB to the Arduino, and have it control the LEDs based on those commands.

That makes sense, do you have any tips on how i should go about handling it this way or any tips on where to look?

GoForSmoke:
What will you use for software on the PC?

I'm not sure what software to use as i'm brand new in the field. Do you have any experience with any software that can help me with my project?

DVDdoug:
Without going into all of the "difficulties", I'll just say, that's probably impossible with that the same time Arduino. Plus, the computer would have to send digital audio to the Arduino plus a soundcard and without special software or drivers the computer can only use one "soundcard" at a time...

It's fairly common to send a line-level (or headphone level) signal to the Arduino, and you can easily "split" the signal, sending it to your amp and the Arduino at the same time.

Just to get you started take a look at my [u]World's Simplest Lighting Effect[/u]. ...It's a pretty boring "flicker" effect so it's mostly just an example but there is a schematic showing how to bias the input so it can read the negative-half of the AC audio signal.

USB can be useful if you have a "programmed show" with the same-exact music and same-exact lighting every night. But if you want it to "react", an analog audio signal is the way to go.

I will give it a look, Thanks for the input. Tbh, I didn't think about using the line-out signal from my PC.

No experience with any PC based sound processing software.

First you have to figure out how you want your lights to react. What exactly should they react to? Volume, rhythm, pitch come to mind. Maybe others. You have to come up with very specific ideas as "reacting to music" is way too vague to even start turning it into something computers can work with.

Second step is to find software that can recognise this, and turn it into a specific command for your LEDs.

Now the easy part. Send that command to the USB port in plain text data, have the Arduino read it (there's a "serial communication basics" thread out here telling you exactly how that works), and control your LEDs accordingly.

wvmarle:
No experience with any PC based sound processing software.

First you have to figure out how you want your lights to react. What exactly should they react to? Volume, rhythm, pitch come to mind. Maybe others. You have to come up with very specific ideas as "reacting to music" is way too vague to even start turning it into something computers can work with.

Second step is to find software that can recognise this, and turn it into a specific command for your LEDs.

Now the easy part. Send that command to the USB port in plain text data, have the Arduino read it (there's a "serial communication basics" thread out here telling you exactly how that works), and control your LEDs accordingly.

I have been messing with some ideas when it comes to the light show itself. I have some idea on how I should mess around with that piece of the code. There is also plenty out there that I can look at. I haven't found anything on the USB side of things, where all I have been finding is the standard ones with the microphone.

Do you know of any software that can do this?

As said no experience with such software. Audacity comes to mind, that can do all kinds of interesting things with audio. Maybe that's suitable for you.

Otherwise replace the microphone signal with a line signal. Mind the voltage level difference between the two.

DavidWilh:
I'm not sure what software to use as i'm brand new in the field. Do you have any experience with any software that can help me with my project?

Nothing that makes COM outputs synchronized to sound.

PJRC has a sound suite to run on their ARM Teensies with audio DACs, it will likely run on a Due, you might do everything on one board with that.

If you can get the sound out of the PC into MIDI, Arduino can read those signals but I've not worked enough with MIDI to say how to get it to read sounds. MIDI is supposed to able to drive lots of leds according to one Arduino article I have read.

Since you're going to have to learn a lot to do anything, you might as well check out options.

Is it possible that the effects you want could be made as circuits driven by sound signal?

MIDI will only work if the original sound file is in MIDI format... but if the source is in MIDI (normal recordings are not) it should be very easy to sync LEDs to it, as MIDI is a kind of musical notation.

If the sounds in this case could be sampled, and I have heard long samples before, a MIDI system could be used to control sound and lights/motors.

MIDI used to run on PC's, maybe still does. The old PC gameport is a MIDI port ready to connect. Now you get a USB to MIDI cable/hub/converter instead.

GoForSmoke:
Nothing that makes COM outputs synchronized to sound.

PJRC has a sound suite to run on their ARM Teensies with audio DACs, it will likely run on a Due, you might do everything on one board with that.

If you can get the sound out of the PC into MIDI, Arduino can read those signals but I've not worked enough with MIDI to say how to get it to read sounds. MIDI is supposed to able to drive lots of leds according to one Arduino article I have read.

Since you're going to have to learn a lot to do anything, you might as well check out options.

Is it possible that the effects you want could be made as circuits driven by sound signal?

I'm currently open to a lot when it comes to the effects, I haven't decided exactly how I want my effects yet. I have some ideas though. But then again, I'm not married to them. Anything would be cool IMO. This is my first real project with my LED's. I already have a rainbow effect running but like I said, I want to make it sound reactive.

I will definitely have a look at PJRC though. I'm currently in the planning phase of it all, so I'm probably missing some components. (and some skill/knowledge)

Get or build a 3-way bandwidth splitter for both audio channels and you have 6 outputs the Arduino could read. That could connect directly to an MP3 player.

Make Magazine has run articles on making effects boxes for musical instruments, a reverb pedal that only reverbs the lights?

Quote from: wvmarle on Apr 23, 2019, 01:27 pm

❝Do the sound processing on the part of your kit that can handle it (i.e. your PC), send the results over the USB to the Arduino, and have it control the LEDs based on those commands.

That makes sense, do you have any tips on how i should go about handling it this way or any tips on where to look?

Real "computer programming" for Windows or OS X is quite a bit more complicated than Arduino programming. Of course there are books and online resources and you have a choice of programming languages but it's probably going to take you weeks or months before you get anything useful. And, it's not just a matter of writing a "little application"... You'll have to "tap into" the sound processing and that my require writing a special driver that allows you to continue using your existing audio player, drivers, and soundcard.

It takes almost no-time to make an analog connection to the Arduino and write a little program to read the analog signal. Of course, it will take more time to do something "interesting" with the readings but overall it's a lot easier.

If you wanted to use the computer you can buy (or build) a [u]DMX[/u] interface and then buy (or build) some DMX lighting. (Most Dance/DJ lights can be DMX controlled.) ...It might be better to use DMX than to design your own-custom USB protocol.

You can buy DMX software, but as far as I know it's for theatrical programming and I don't know if you can get DMX software that reacts to sound. I think you can buy a stand-alone DMX controller with an audio input, and of course you could build a DMX controller that reacts to sound.

GoForSmoke:
Get or build a 3-way bandwidth splitter for both audio channels and you have 6 outputs the Arduino could read. That could connect directly to an MP3 player.

Make Magazine has run articles on making effects boxes for musical instruments, a reverb pedal that only reverbs the lights?

Maybe i should do that!
Thanks for all the help and suggestions everyone, I'll try to see if I figure something out.
I'll post a follow up when and if i get it working.

Again, Thank you all!

Arduino is capable of detecting beats as groups of average high analog reads but it's not good for audio frequency in or out.

Human eyes only see so fast (though a 5ms bright flash will persist to be seen a 5ms OFF is undetectable); 24FPS is seen as motion, 30FPS is TV, 60FPS is better but figure that 50FPS is good.

What 50 FPS means is changing all the lights every 1000/50 = 20 milliseconds. That's 320000 cpu cycles. At Arduino Speed, 20 millis =is= a long time. Even if you waste it with delay(20) it's just a long time wasted so get into non-blocking code!

With non-blocking code Arduino can do an amazing amount per millisecond as multiple small tasks handling inputs and generating outputs. I have examples with buttons/leds/serial posted showing how many times void loop() ran every second at over 67KHz, that's check every task and run the ones needed (like the 32-bit loop count and show task) 67 times on average every millisecond --- that's doing light work but Arduino has plenty of do-it in just 1 milli to run many tasks at once.

Say you have a task that analog reads V on left channel bass one ms, mid-range next ms and treble next ms leaving time between for other tasks between then turn those into RGB for the next addressable led in sequence and then wait for the next 20 ms frame to RGB the next led and the color string moves at 50 leds a second.

You take the input that means one thing and apply to something else as another meaning, abstraction. Works with circuits, works with art, works with coding too.

If you don't know the language up to variables and arrays, loops and if-else/switch-case logic then get at least that far just to save yourself wasting major time typing and debugging huge messes. Never fear, there's more but this basic set can do a lot pretty easily.

I can think of 3 ways to get audio from a USB:

  1. Find some old USB headphones and cannibalize them for the chip and audio output.
  2. Find some old Bluetooth headphones that come with a dongle (or without, if you don't care about using a USB).
  3. Buy an external sound card (for 7 US dollars on amazon) and plug the arduino into the audio jack.

I have tried messing around with this myself a few weeks ago, and I would like to see how your project turns out! You will need to put a 10k resistor from the analog pin to ground pin, and another 10k resistor from the analog pin to the 5 volts pin. Get your audio hooked up and try watching the values in the serial monitor.

void setup() {
  Serial.begin(9600); //begin serial at 9600 baud.
}

void loop() {
  Serial.println(analogRead(0)); //read analog pin 0
  delay(100);
}

I hope you can get this working! :slight_smile: