Can a HC-05 be used to receive music? - Page 1
Forum section: electronics / beginners

author: skillz21
author_rank: Frequent Contributor
timestamp: December 17, 2017, 03:18:15 am
content: Ok, so I did google this and everyone seems to be saying no, because the HC-05 is a serial com device and whatnot... but is it not possible to somehow use some code at the computer, to convert the music to... text? Somehow? And use an Arduino at the receiving end to put it back together? I know I should just buy a dedicated module for this, but that's not the point here, I just want to know whether it can be done, and if I can replicate it myself.Thanks!

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: December 17, 2017, 04:14:21 am
content: Short answer: No. You need a Bluetooth module that supports A2DP.You might be able to hack something together to stream chunks of audio but you will have to have a big buffer in place and would have to write your own packet based protocol.The only supported Bluetooth profile for the HC-05 is SPP with a maximum payload of 128bytes. The problem is, that you are sending synchronous data over an asynchronous packet network. I don’t want to say it is impossible to stream audio (I guess that is what you mean). Sending a file dump over SPP is something completely different.See also:https://forum.arduino.cc/index.php?topic=208306.0In my opinion there is very little to gain and I would spare the time and just buy a suitable Bluetooth module.

author: skillz21
author_rank: Frequent Contributor
timestamp: December 17, 2017, 04:26:53 am
content: Quote from: frozenfrogz on December 17, 2017, 04:14:21 amYes I know this, I want to do this for the experience, not the final product..... Thanks for your help anyway.

author: skillz21
author_rank: Frequent Contributor
timestamp: December 17, 2017, 04:30:35 am
content: Also, does anyone have a clue as to how I would go about writing a program to convert sound to 1s and 0s? In c++? Like... Any general pointers or ideas you could give me?

author: mariush
author_rank: Super Contributor
timestamp: December 17, 2017, 05:47:56 am
content: Just read up (google) how a WAV file is stored. You have a number of bits per sample (8 bit , 16 bit and 24 bit per sample are the most common) and then you have the frequency, the number of samples per second .. values like 11025 , 22100 , 44100 Hz (cd music) , 48000 are very common...So a CD quality audio file will require 2 channels x 2 bytes (16bit per sample) x 44100 (samples per second) = 176,400 bytes per secondFor just human voice, you could go down to mono (1 channel) and 11025 hz and 8 bit per sample and that's basically 11 KB/s of uncompressed audio.If you compress with some audio codec like Opus for example, you can squeeze that in 1-2KB/s easily.

author: skillz21
author_rank: Frequent Contributor
timestamp: December 17, 2017, 09:37:48 am
content: I was thinking more along the lines of making a program that takes the master audio output of the computer, and then broke that down to 1 and 0.... not exactly individual files.... Any ideas?

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: December 17, 2017, 12:45:56 pm
content: That is what an ADC does, but what’s the point? If you are playing a sound file on a computer it gets put through a DAC to convert the digital 1s and 0s of the file to analog voltages.

author: Masa
author_rank: Contributor
timestamp: December 17, 2017, 09:41:29 pm
content: Audio files on a computer are stored like any other files, so sure you can send them over serial.It requires a little bit of programming on both ends.There is encoding methods, for encoding binary data into text format. You could take a look at Base64 encoding for example:https://en.wikipedia.org/wiki/Base64I don't know what kind of data rate's the system you are talking about supports, or how much processing power, memory, etc. it has, so these may set a limit.Sending all sound from a computer is probably possible, but it is easiest to start just by sending only a file at a time and first figuring out how can you play that file.There is a tool called SoX that might be useful in converting audio files into more raw formats :http://sox.sourceforge.net/