shorepine / amy

AMY - A high-performance fixed-point Music synthesizer librarY for microcontrollers
https://shorepine.github.io/amy/
MIT License
224 stars 14 forks source link

AMY_Test_Pi_Pico.ino Sample Rate #183

Closed phesterman closed 3 months ago

phesterman commented 3 months ago

I just discovered that the sample rate (AMY_SAMPLE_RATE) is twice the frequency it should be, so each example sounds an octave higher. I don't know if this is the right way to handle it, but changing line 14 to "i2s.begin(AMY_SAMPLE_RATE/2);" fixes it.

Peter

bwhitman commented 3 months ago

This probably is more likely due to the code sending mono data in a stereo channel (so you're sending data twice as fast as you need to.) I haven't tested this example in a while but i wonder if we're not setting stereo/mono in the i2s setup according to what AMY_NCHANS is.

phesterman commented 3 months ago

Yes, that makes sense. My I2S device is a Pimoroni Pico Audio Pack which is stereo-capable.

bwhitman commented 3 months ago

I've fixed this up in the example by explicitly sending two channels (even though AMY is rendering in mono for this example.) So either render AMY in stereo, or do what I do now in the AMY_Test_Pi_Pico and send mono channel twice. It looks like the arduino-pico i2s module only supports stereo.