Hi,
it is not foreseen yet to change the pitch yet, at least not in fine amounts. You can select between half or full-rate, but that's all. If you want to change the playback speed in finer amounts, it is not possible with that library yet and you wont get usable result just by changing the timer rate because the timer already runs at relatively high speed allowing only massive pitch changes.
The easiest way to do such things might be to prepare multiple files on the card each with a different pitch and play those. You can do this using an audio editor like Audacity to prepare such files.
If you really want to go the hard way it should be possible to modify the library to support different playback rates - at least two options came in mind for me, changing the playback-interrupt function or the worker-function. The worker-function is written in plain C and should be easier to modify but with rate-changing it would not be longer operating at sector boundaries. In the playback function rate changing only have influence over buffer empty speed but it is harder to understand as it is written in Asm. The algorithm I would prefer is a phase-accumulator that decides if and how many samples are skipped or repeated for every target sample...
Thank you tuttut for the reply.
OK, I take the easy way you have mentioned.
One more question. I need to play a 5sec audio as a seamless loop:indefinitely .Though I am able to accomplish that with the "Bare minimum" you have provided,there occurs an audio glitch at the end-to-beginning of the file played. The file has perfect zero-crossing at the beginning and in the end.Could you please suggest anything to avoid this problem.
(My gadget: Ardiuno Atmega 328+LC studio SDcard breakout board).
Thank you again.
Hi,
Sorry, that patch did not work.
Result : Audio file not played.Instead, there were lot of glitches-only glitches.I have noticed that the glitches came out as a stream (loudest at the start and diminished along the time line and died in few seconds).But that was from "Bare minimum" sketch.
When I tried the " Bare minimum with Debug", it gave a continuous tone of 125 hz approx.(No audio file content played).
But, sketch examples with worker (bare minimum with worker,bare minimum with worker with debug),worked normally,of course with the glitch.
Could you please explain what exactly the patch modifies.
Anyway, thank you for trying to help me.
Hi,
sorry, I did the patch using a too old local copy of the library on my smartphone on-the-go and got an too old lib file. Now I edited my former post, please try to apply the patch again on SimpleSDAudio-Lib V1.03 (the current one). This time I tested it a little. Unfortunately actually there is no flag that tells you if the file played at least once...
Please try again and tell me if it is working for you.
BTW: The patch catches the moment when the worker function puts the last sector (or part of it) of the audio file in the playback buffer. In this case, it waits endless (and therefore precise) until the buffer is completely empty (_Buflen == 0). In this moment it triggers the play() function, which starts the playback again. This is how the play() function works - if playback is still playing it restarts playing from start again (done by calling internally the stop() function). The stop() function resets all the pointer and the buffer for the playback.
I'm still getting audio glitch.May be,something wrong (sd card format etc)with my setup.Could you please confirm that the test file I am using (please see attachment)works Ok in your set up?
: Thank you for the explanation about the patch.Now I understand little more about the 'worker' function and I try to understand your libs more deep.
Hi @manmachine: Hm, I thought about my quick solution and it is wrong - the issue is that the buffer is completely empty when issuing play and that play first reads a whole sector of 512 bytes from card before it starts playback again. This should lead to a fast but not gapless start. I think it will need a bigger overwork to get around this. I could think about modifying the lib to read the sectors byte-wise which will make the lib slower but more flexible. Audio processing will then become possible like gapless playback, fine-tuned playback tempo and mixing. But the lib might be then not as simple to use as now.
@meow...: Please provide more info what is working and what not. Error code of lib or just no sound? Or just no sound in bigger software project?
Hi, @Tuttut:Thank you for your reply.So, its going to be a different approach!Well,Could you post a FLOW CHART of the proposed lib implementation,what might be a possible solution.
Tuttut, thanks for the great library. I have an alpha release of my ChipKit port, BasicSDAudio, available on GitHub. I am also working on an amplifier board that would work for any PWM audio output.
I'd like to see/learn more about making this Awesome library better sounding with the use of filter/amp?
Small? (all SMD?)
Is there a schematic posted for it?
I am VERY happy Tuttut released this lib.. it was a HUGE missing part of the Arduino community (easy audio)..
but as 'stock' the volume is just 'meh'... so it needs some filters and an amp for sure for more sound hungry projects..
still learning/finding my way through filters and amps..