Go Down

Topic: Using USB to send sound signals (Read 384 times) previous topic - next topic

DVDdoug

#15
Apr 24, 2019, 07:31 pm Last Edit: Apr 24, 2019, 07:52 pm by DVDdoug
Quote
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 DMX 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.

DavidWilh

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!

GoForSmoke

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.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

KingDubDub

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.

Code: [Select]

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!  :)

Go Up