Forum

Audio is Playing Too Fast or Too Slow

More
#9 by foxonix
foxonix created the topic: Audio is Playing Too Fast or Too Slow
You may notice that the playback speed of the audio does not exactly match the speed of the original audio file. This is because the clock speed of the chip (and therefor the audio clock) are controlled by resistor Rosc. The required value of this resistor is 180kOhm, but there is always some variation in the actual value. As a result, the playback speed of the audio may vary a little bit.

If the playback speed is way off, it may be because the freq rate set in the program does not match the sample rate of the audio file. Check to see that the sample rate of the audio file and the freq rate in the program are the same.

Foxonix - make your ideas heard.
@foxonixdev

Please Log in or Create an account to join the conversation.

More
#567 by ericleven
ericleven replied the topic: Audio is Playing Too Fast or Too Slow
Pardon my ignorance (what the heck is a Rosc?), but I'm wondering: is there a way to predict what the speed change will be? The audio that I load to the board is playing back fast (an unscientific test puts it at about 106% speed of the original). If it's always going to play that fast, should I change my sample rate to compensate?

Thanks,

-eric

Please Log in or Create an account to join the conversation.

More
#568 by foxonix
foxonix replied the topic: Audio is Playing Too Fast or Too Slow
Hi Eric:

No problem - these are all good questions I'm sure other users will find useful. The chip uses a resistor to set the system clock speed, which controls the timing of everything that happens in the chip. Both the Fox Board and the Project Board have this resistor. You'll see it on the board labeled Rosc, which is shorthand for "oscillator resistor." The nominal value of this resistor is 180k, but it can be changed to slow down or speed up the system clock, which has the effect of altering the audio playback speed, too. If your audio is playing too fast, a 200k resistor could be used instead of the 180k resistor. This is a good overall solution because it sets the sample rate for that particular board.

Changing this resistor may not be practical for some users, so luckily there is another solution you can use which changes the playback sample rate from within the program. The freq command is used in the program to set the playback sample rate. You can set this to a lower sample rate, like freq=11.9k, which will cause your audio to play back slower. This is nice because you don't need to update the sample rate of your source audio files. (We normally don't recommend tweaking the sample rate of your audio to fix speed issues.)

So in your program you would replace this command:
freq=12k

with this command:
freq=11.9k

Additionally, you can set the playback sample rate for effect, for example if you wanted to slow the audio way down to make it sound really sluggish, or speed it way up for a "chipmunk" effect.

Foxonix - make your ideas heard.
@foxonixdev

Please Log in or Create an account to join the conversation.

More
#569 by ericleven
ericleven replied the topic: Audio is Playing Too Fast or Too Slow
Thanks for the info! Some followup questions:

Is there a way to measure the value of resistor Rosc with a multimeter so I can change the frequency to precisely the correct value?

Should I assume the value of Rosc will change from board to board (so if I get the correct freq value on the Fox board, I'll need to re-adjust on my Project board)?

What causes the Rosc value to change? When I buy a pack of 220ohm resistors, they always seem to be exactly 220ohm.

Thanks again,

-eric

Please Log in or Create an account to join the conversation.

More
#571 by foxonix
foxonix replied the topic: Audio is Playing Too Fast or Too Slow
Hi Eric:

You can measure the value of Rosc with a multimeter pretty easily. On the Fox board this resistor is labeled ROSC and can be found a bit to the right of the fox head logo. On the Project Board this resistor is labeled OSC and can be found right underneath the P6.0 pad. We use a very accurate resistor for this (0.1% tolerance), and most of the time 180k works well. Sometimes you do need to go up to 200k if the audio is really playing too fast, and we're pretty sure this is due to variation in the chips themselves and not just the resistor.

Because of this it's possible that you would need to set this for each Project Board, but that's not usually the case. You may program your Project Board and then find that the playback speed is fine. It also depends on how accurate you need your audio to be. For many applications it's not critical for the playback speed or pitch to be 100% spot on, like with sound effects and speech, for example. For music playback where you need exact pitch, then this would be more critical.

Foxonix - make your ideas heard.
@foxonixdev

Please Log in or Create an account to join the conversation.

More
#575 by ericleven
ericleven replied the topic: Audio is Playing Too Fast or Too Slow
So I've adjusting my freq to compensate for the playback pitch of my audio, and getting odd results. I'm using 20khz audio files, 'cause I figured, why not have the highest quality audio the chip is capable of?

20k plays the audio too fast.
19k plays the audio too slow.

I've been slowly changing the freq value and I finally noticed that there's only "too fast" and "too slow"; the freq doesn't seem to gradually adjust the pitch. So basically, anything larger than 19.2 is too fast, and 19.2 and below is too slow. There's no way to get more accurate than that.

Is that correct? Or am I missing something?

Thanks,

-eric

PS: When you get tired of me (and only me) posting silly questions, please let me know. =]

Please Log in or Create an account to join the conversation.

Time to create page: 0.021 seconds