Audio usb to arduino?

Hello, I'm very new to the arduino.

But I want to send light to my single led on the music, so I can make a small visualizer. but how do I send audio (data) to my arduino, and how can I use that data

Any help/link would be appreciated.

https://www.hobbyist.co.nz/?q=making-led-lights-dance-to-your-music

Grumpy_Mike:
https://www.hobbyist.co.nz/?q=making-led-lights-dance-to-your-music

Looks useful, the only thing is, my headset is a USB. so I need to read the data from that (I might be able to ask data from my computer using the serial port?)

my headset is a USB

Then forget it. The Arduino USB only looks like a serial port. Never come across a USB head set can you post a link?

There are two problems... The Arduino won't be seen as a soundcard by the drivers (it's not fast enough to work as a soundcard and if it was powerful enough you'd have to write the firmware). And, by default Windows can only send audio to one device at a time.

You can "split" the analog audio signal, but not the USB.

Grumpy_Mike:
Then forget it. The Arduino USB only looks like a serial port. Never come across a USB head set can you post a link?

https://www.amazon.com/Razer-Kraken-Chroma-Gaming-Headset/dp/B01LZM1WRC

DVDdoug:
There are two problems... The Arduino won't be seen as a soundcard by the drivers (it's not fast enough to work as a soundcard and if it was powerful enough you'd have to write the firmware). And, by default Windows can only send audio to one device at a time.

You can "split" the analog audio signal, but not the USB.

Hmm alright, then I'll try to use processing to do the hard tasks on my computer and send data like bass=100 to my arduino to control some leds.

@InstantlyMoist please don't cross post.
The other thread has been removed.

Okay so I changed it, i'm trying to process data on my pc now using Intellij. I have my audio bytes, but how would I send proper data to my arduino? Like audio intensity.

You send data to the Arduino through the serial port. At the Arduino end you take that number and do something with it.

Hmm yea but the problem is, I have the audio data now. But I don't know how to convert that into things like audio intensity.

What do you mean by audio intensity?
I suspect you mean amplitude.
You have a stream of numbers representing the audio signal, if you want to measure the peak amplitude then you need to track the numbers until you reach a local peak. That is set the peak value at zero and comparing that with the next number. If it is larger than your peak you make it the peak value. When this next number is lower than your accumulated peak, you have found a local peak and you send that number to the Arduino.

Grumpy_Mike:
What do you mean by audio intensity?
I suspect you mean amplitude.
You have a stream of numbers representing the audio signal, if you want to measure the peak amplitude then you need to track the numbers until you reach a local peak. That is set the peak value at zero and comparing that with the next number. If it is larger than your peak you make it the peak value. When this next number is lower than your accumulated peak, you have found a local peak and you send that number to the Arduino.

But I only have numbers that go from -255 to 255, and how would I read every byte fast enough?

That is your problem you said you already had these numbers, and if you have your computer must be fast enough to process them so you can do that algorithm.

The main problem as I see it is that you do not know what you have. And you are having trouble expressing what you want to do. You seem not to have the data in a form you can’t do anything with so like I said in reply #3 forget it.

If you can turn it into an audio signal then game on but you don’t seem to be able to do this.

Grumpy_Mike:
That is your problem you said you already had these numbers, and if you have your computer must be fast enough to process them so you can do that algorithm.

The main problem as I see it is that you do not know what you have. And you are having trouble expressing what you want to do. You seem not to have the data in a form you can’t do anything with so like I said in reply #3 forget it.

If you can turn it into an audio signal then game on but you don’t seem to be able to do this.

indeed thats why im asking help :stuck_out_tongue: I just need an example so I know what I should do.

indeed thats why im asking help

My help is that you can not do what you want to do using an Arduino.

Unless you can come up with a better explanation what you have and the code you have on your PC then your project is a none starter.

Grumpy_Mike:
My help is that you can not do what you want to do using an Arduino.

Unless you can come up with a better explanation what you have and the code you have on your PC then your project is a none starter.

Aha yes ofcourse,

So my final plan would be to create a led strip visualizer controlled by my arduino. For that I need the audio that is sent to my headset, I have that with the following code:
https://hastebin.com/ekapupuqil.swift

^This is just a pastebin but faster, no virus.

This gives me a raw output with numbers from -255 to 255, though this isn't usable to send to my arduino.

My question here is, how would I get needed data from those bytes (Like decibels, volume, audio intensity, frequenty) and stuff like that. I think -255 till 255 is giving me some kind of wave-form but I'm not sure.

Going round in circles here.

. I think -255 till 255 is giving me some kind of wave-form but I'm not sure.

What makes you think it is -255 to 255, it is a byte array so you can only represent -128 to 127. The code is filling an 80K buffer with samples so this is way more data than an Arduino has. A Uno only has 2K of data. That code is part of some other code that uses a processor that is very much faster than the 16MHz of an Arduino, and perhaps uses DMA buffers along the way.

Maybe the best thing you could do is to take the average of all the positive numbers in the buffer and send that to the Arduino then you might get something related to the music, but an Arduino is not suited to process the data you have at the moment.

Grumpy_Mike:
Going round in circles here.What makes you think it is -255 to 255, it is a byte array so you can only represent -128 to 127. The code is filling an 80K buffer with samples so this is way more data than an Arduino has. A Uno only has 2K of data. That code is part of some other code that uses a processor that is very much faster than the 16MHz of an Arduino, and perhaps uses DMA buffers along the way.

Maybe the best thing you could do is to take the average of all the positive numbers in the buffer and send that to the Arduino then you might get something related to the music, but an Arduino is not suited to process the data you have at the moment.

So, in every time the while (read > 0) runs I should send the average to my arduino?

No you should add that value to a total, probably as an int or long int and count how many have been added. Then divide the total by the number of samples and send the resulting byte to the Arduino. Then use that value to set the PWM value of an LED.

Grumpy_Mike:
No you should add that value to a total, probably as an int or long int and count how many have been added. Then divide the total by the number of samples and send the resulting byte to the Arduino. Then use that value to set the PWM value of an LED.

Could you give me an example?

I dont see what I should do and where. in my while loop i have to get the average and count that and then devide by the number of times i did that. but after a long time the average will be 0, right?