Author Topic: Can a HC-05 be used to receive music?  (Read 5495 times)

0 Members and 1 Guest are viewing this topic.

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Can a HC-05 be used to receive music?
« on: December 17, 2017, 03:18:15 am »
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!
 

Offline frozenfrogz

  • Frequent Contributor
  • **
  • Posts: 936
  • Country: de
  • Having fun with Arduino and Raspberry Pi
Re: Can a HC-05 be used to receive music?
« Reply #1 on: December 17, 2017, 04:14:21 am »
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.0

In my opinion there is very little to gain and I would spare the time and just buy a suitable Bluetooth module.
He’s like a trained ape. Without the training.
 

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Can a HC-05 be used to receive music?
« Reply #2 on: December 17, 2017, 04:26:53 am »
In my opinion there is very little to gain and I would spare the time and just buy a suitable Bluetooth module.
Yes I know this, I want to do this for the experience, not the final product..... Thanks for your help anyway.
 

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Can a HC-05 be used to receive music?
« Reply #3 on: December 17, 2017, 04:30:35 am »
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?
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 4982
  • Country: ro
  • .
Re: Can a HC-05 be used to receive music?
« Reply #4 on: December 17, 2017, 05:47:56 am »
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 second

For 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.


 

Offline skillz21Topic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
Re: Can a HC-05 be used to receive music?
« Reply #5 on: December 17, 2017, 09:37:48 am »
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?
 

Offline frozenfrogz

  • Frequent Contributor
  • **
  • Posts: 936
  • Country: de
  • Having fun with Arduino and Raspberry Pi
Re: Can a HC-05 be used to receive music?
« Reply #6 on: December 17, 2017, 12:45:56 pm »
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.  :-//
He’s like a trained ape. Without the training.
 

Offline Masa

  • Contributor
  • Posts: 20
  • Country: fi
Re: Can a HC-05 be used to receive music?
« Reply #7 on: December 17, 2017, 09:41:29 pm »
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/Base64

I 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/
« Last Edit: December 17, 2017, 09:55:02 pm by Masa »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf