Audio streaming
Audio streaming
Hi,
Iv been playing with the audio streaming file found in one of the topics, its for streaming wav files from a sd card.
I have it all setup and working ok, however the sound quality is a lot worse than i expected, it sounds like its underwater. Also to go with it there is this constant pulsing noise that overpowers the actual audio. iv tried basic filtering on the PWM but the whole audio seems to get quieter, not just the clicking, is it normal for the PWM to make this clicking noise anyway?
Iv been playing with the audio streaming file found in one of the topics, its for streaming wav files from a sd card.
I have it all setup and working ok, however the sound quality is a lot worse than i expected, it sounds like its underwater. Also to go with it there is this constant pulsing noise that overpowers the actual audio. iv tried basic filtering on the PWM but the whole audio seems to get quieter, not just the clicking, is it normal for the PWM to make this clicking noise anyway?
Re: Audio streaming
I have just tried it using a DAC and putting the output to port B, the pulsing is still there so i assume its something to do with how the output is generated. Also the output is terrible, you can just about make out whats being said through loads of static.
Re: Audio streaming
A little bit of progress made, because i have dropped the frequency to 19.6608Mhz, it resulted in the PWM frequency dropping into the audiable range. I have altered the PWM slightly to put it outside audio range. That takes care of the high pitch squealing.
I have still not been able to get rid of the static clicking noise, iv looked at it on a spectrum analyser and the static clicking noise is in the higher end of the audio, filtering it takes too much audio content away.
It appears that the noise is possible being created from the decoding in some way. I have generated a triangle wave using the exact same hardware setup outputting it through PWM and i get a crystal clear note generated.
My conclusion is that the noise is being injectected somewhere between coming from the card and out of the PWM. Does anyone know what could cause this?
I have an audio file with the noise on it, but i cant figure out how to upload it here.
I have still not been able to get rid of the static clicking noise, iv looked at it on a spectrum analyser and the static clicking noise is in the higher end of the audio, filtering it takes too much audio content away.
It appears that the noise is possible being created from the decoding in some way. I have generated a triangle wave using the exact same hardware setup outputting it through PWM and i get a crystal clear note generated.
My conclusion is that the noise is being injectected somewhere between coming from the card and out of the PWM. Does anyone know what could cause this?
I have an audio file with the noise on it, but i cant figure out how to upload it here.
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
Re: Audio streaming
Could you upload your *.c file and *.fcf file ?
I'd like to see what the decoder looks like.
Nicolas
I'd like to see what the decoder looks like.
Nicolas
Re: Audio streaming
Ok, so i have increased the speed upto 64Mhz incase it was a speed issue. Some of the static noise has gone, but there is a prominent clicking noise while streaming. The clicking sounds like static, think of an old LP playing, its thats sort of noise but it has a sort of frequency. By that i mean like it happens with constant spacing. its really fast tho so i couldnt say how much spacing.
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
Re: Audio streaming
Hi,
I downloaded Benj's zip and read the whole *.c file.
I must say I'm getting a headache of all that code. I didn't know it would be so difficult and so much code to just read from an SD card.
I'm afraid I can't help you with this, you'll have to wait for Benj or other MM staff to help you tomorrow.
Nicolas.
I downloaded Benj's zip and read the whole *.c file.
I must say I'm getting a headache of all that code. I didn't know it would be so difficult and so much code to just read from an SD card.
I'm afraid I can't help you with this, you'll have to wait for Benj or other MM staff to help you tomorrow.
Nicolas.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Audio streaming
Hello,
The noise you can hear is described in the article text. Maybe something slightly wrong with the double buffering in your program at your clock speed.I have still not been able to get rid of the static clicking noise
Both the PICmicro and the ARM Flowcode examples employ a buffering scheme to allow the audio data to be streamed without causing ticks or glitches in the playback audio signal. The files are read from the memory card in chunks of 512 bytes called sectors. Two neighbouring sectors of the file may not be located one after another on the physical card memory so there is a small amount of time to seek out and read the next sector for the card. Don't worry this is all handled automatically by the Flowcode FAT16 driver. However it does mean that the previously mentioned buffering technique needs to be used to keep the audio streaming correctly. As each set of 512 bytes is loaded there is a timer interrupt that starts streaming out the data. While this is happening a section at the end of the 512 bytes is stored into a local array. This is done so that when the timer interrupt is nearing the end of the 512 bytes it can stream the audio from the local buffer while the FAT routine is moving and collecting the next file sector.
Yes unfortunately it is not as straight forward as it first seems to read/write a file on a card and allow it to remain compatible with PCs etc. Thankfully the Flowcode component now existsI must say I'm getting a headache of all that code. I didn't know it would be so difficult and so much code to just read from an SD card.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Audio streaming
Hi Ben
Thanks for your reply. I read that part of the article, I know its the buffer that stops the noise. Problem is there's not really much in the buffer part of the code to change. Its just a loop really.
One thing I did notice that I jusyt wanted to check was whencompiling I get an error saying that the read from buffer macro is called asyncronous and could cause corruption. In your origional flowchart with no modifications I get that same error. Is this something that could cause the ticking?
Thanks for your reply. I read that part of the article, I know its the buffer that stops the noise. Problem is there's not really much in the buffer part of the code to change. Its just a loop really.
One thing I did notice that I jusyt wanted to check was whencompiling I get an error saying that the read from buffer macro is called asyncronous and could cause corruption. In your origional flowchart with no modifications I get that same error. Is this something that could cause the ticking?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Audio streaming
Hello,
This is the part causing the ticking. Try playing with the number of bytes stored in the secondary buffer.Problem is there's not really much in the buffer part of the code to change. Its just a loop really.
No this is not the cause of the problem and is not cause for worry in this instance.One thing I did notice that I jusyt wanted to check was when compiling I get an error saying that the read from buffer macro is called asyncronous and could cause corruption. In your origional flowchart with no modifications I get that same error. Is this something that could cause the ticking?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Audio streaming
Hello,
Yes try changing the number of bytes that are passed into the backup buffer. You will probably have to change the normal buffer to match.
Also are you using the FAT component or are you still using the custom version of the component? I would advise using the FAT component as this should be more reliable code.
Have a go and see where you get and then post your program up if you cannot proceed any further.
Yes try changing the number of bytes that are passed into the backup buffer. You will probably have to change the normal buffer to match.
Also are you using the FAT component or are you still using the custom version of the component? I would advise using the FAT component as this should be more reliable code.
Have a go and see where you get and then post your program up if you cannot proceed any further.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Audio streaming
There are two buffers. One runs from 0-400 and the other runs from 0 to 112 to make up the sector size of 512 bytes.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Audio streaming
Hi Ben,
Ok, so i played with the buffers a bit, when altering one buffer i balanced the other out to always give 512.
So heres what happened, when reducing the bytes in the buffer below around 100 bytes i heard a prominent clicking, this is as described in your article, if i increase the bytes in the buffer this static sound im getting becomes louder and more overpowering. Filtering does nothing, i actually managed to filter out most of the audio today and still this static noise was there.
I have a feeling i am not going to be able to solve this easily.
Ok, so i played with the buffers a bit, when altering one buffer i balanced the other out to always give 512.
So heres what happened, when reducing the bytes in the buffer below around 100 bytes i heard a prominent clicking, this is as described in your article, if i increase the bytes in the buffer this static sound im getting becomes louder and more overpowering. Filtering does nothing, i actually managed to filter out most of the audio today and still this static noise was there.
I have a feeling i am not going to be able to solve this easily.
Re: Audio streaming
Hi.
So iv been trying different things and still can't get rid of this crappy sound. I had a chat with a few friends and they say it might be better to read the audio directly from an array at the cost of program memory. Since I have loads of memory I think this is a better option. However since they don't know flowcode they don't know how to do it. Is this something you could help with??
So iv been trying different things and still can't get rid of this crappy sound. I had a chat with a few friends and they say it might be better to read the audio directly from an array at the cost of program memory. Since I have loads of memory I think this is a better option. However since they don't know flowcode they don't know how to do it. Is this something you could help with??
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Audio streaming
Hello,
What speed are you running your device? I had the code running on a PIC ECIO running at 48MHz and this was working nicely. If your clock speed is too low then the FAT routines may be taking too long which is causing the clicking you are hearing. Reading the audio directly from the ROM memory would be a lot faster but means hard coding the data into your program. You can create ROM arrays of data but they can only be a maximum of 256 bytes in length. At 8KHz one buffer would last around 0.032 seconds.
What speed are you running your device? I had the code running on a PIC ECIO running at 48MHz and this was working nicely. If your clock speed is too low then the FAT routines may be taking too long which is causing the clicking you are hearing. Reading the audio directly from the ROM memory would be a lot faster but means hard coding the data into your program. You can create ROM arrays of data but they can only be a maximum of 256 bytes in length. At 8KHz one buffer would last around 0.032 seconds.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Audio streaming
I haven't tried it yet. I think it's normal for the PWM to make this clicking noise anyway. To know more about this you should visit to-: http://www.maurymw.com.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Audio streaming
The main article details how to get rid of the clicking sound. Basically there are two buffers, one which is filled while the second is playing and visa versa. This also allows additions file seeking time etc. If the buffer sizes are not balanced for your application then you will get the clicking sound as the mechanism comes across data that is not ready loaded in the buffer yet.
You could potentially read the file from the card and store the data into RAM using an array at the start of your program. A 16-bit PIC or AVR would allow you to do this but an 8-bit PIC can only have a maximum array size of 256 bytes.
You could potentially read the file from the card and store the data into RAM using an array at the start of your program. A 16-bit PIC or AVR would allow you to do this but an 8-bit PIC can only have a maximum array size of 256 bytes.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel