WaveplayerEx

...i processed the files again (with ffmpeg) and used three folders (pp/mf/ff) now - !much! better...
I'll upload them later to github.

So.. small folders, and do not place more files than needed on the card (finding files needs time)
 

Attachments

  • unbenannt.zip
    66.1 KB · Views: 64
Last edited:
Hi, yes your recording sounds like a speed problem.
You could try to increase AUDIO_BLOCK_SAMPLES to 512 - does it disappear?

I'll upload a recording later... killed everything here and windows is confused with usb audio now.. does not work anymore :) I hope i get it running again :)

It definitely got much better by changing the AUDIO_BLOCK_SAMPLES from 128 to 512, but there are still noticeable cracks in the audio. I will try the new files later!

-Miro
 
Hi,

i fixed a minor issue (along with some other very minor details) where, for aiff, 4 zero where inserted before playing the file.
I'm now very sure, that the waveplayer does not produce any clicks when starting a file. Only, probably, when the card is too slow re: opening files.
So, if there are clicks, either the card, or the samples are the reason.
It helps

a) to use a fast card,
b) to increase the AUDIO_BLOCK_SAMPLES (256 should be enough)
c) use small directories with a few files,

The player is not responsible for slow accesses, if appearend, and I can't do anything.

The, I tried to create better samples, but my ffmpeg knowlage is limited - and after 2 hours I decided to leave them as they are. My new files had other issues (too short) It has nothing todo with the player, so... i'll leave it for others. The link to the used samples is given in the sourcecode of the example. The main problem with the originals is the long pause at start.

I hope someone with more patience does a PR :)

Have fun,
Frank


p.s. Here are 2 ffmpeg commands i used. maybe they are useful:
Code:
volume:
ffmpeg -i %%i -af volume=1.1 conv\%%i 

remove silence:
ffmpeg -i %%i -af silenceremove=start_periods=1:start_silence=0.01:start_threshold=-50dB,areverse,silenceremove=start_periods=1:start_silence=0.5:start_threshold=-60dB,areverse conv\%%i

%%i is the filename. You need to tune the used parameters.

p.s.s:
You can just measure the time the time for opening. use micros() to measure the time for open(filename).
I had times well below 2.9ms (usually around..1.5ms) - and very rarely around 3ms. A 128 sample Audioblock is 2.9ms. So, with 256, you're on the safe side.

p.s.ss: No need to try littlfs on external flash (qspi) It's dead slow and often had times > 20ms when I measured this some months ago.
I did not see any hint that this was fixed.
 
Last edited:
Thanks a lot for your efforts. Frank!

I will go and buy the recommended SD card to see if that helps with the troubles I'm having. It's only around 15 euros here so definitely worth the shot.
I'll also go through the original sample test files and see if I can trim and make them better. I'll report back when I have the new card.

Thanks on the heads up for littlefs too. Looks like I'll stick with SD cards for now.

-Miro
 
Before buying a new card you can also try the official SD Formatter - Bill Greiman (the SDFat "God") and others say, it's better than Windows (or other OS) and optimizes the FAT better.
 
I reformatted my SD card with the SD Formatter and rearranged the audio files into three folders as per your example. The crackle is almost completely gone! There is just a very faint audible click every time a new audio file starts playing. And this is with eight files playing simultaneously. It's pretty impressive stuff, way better than the standard wav player in the audio library.

My next step is to process all the audio files from the original samples to raw files. Let's see if that helps. I also ordered the faster SD card so let's see if that makes any difference when it arrives.

-Miro
 
I have finally managed to fix the click.

I updated to the newest version of the WaveplayerEx and upgraded my sd card during this process, but finally the solution that stopped all the clicks was adding an envelope for each Waveplayer.
It seems that the click was not coming from the new file that started to play but rather from the old file that stopped playing abruptly. I am not experiencing any clicks or other unwanted sounds at the moment when playing with eight note polyphony.

This is great! I will try to add even more polyphony later on.

On another note, are you still considering adding recording capabilities to this audio object? I remember reading about that somewhere.

Best,
Miro
 
Awsome :)

Recording: Yes, you can enable recording (there is #if 0 in both, the .h and the .cpp file)
But recording has even tighter requirements on timing and it's not testedt. It likely that it will not work for you.
 
So far so good with testing the WaveplayerEx for my project. I have managed to make a drum sampler that can be played quite reliably. I was testing it really hard and smashing a lot of keys on my keyboard and I'm getting some clicks still. To solve this, I tried to allocate more memory for the players with the static addMemoryForRead(mult) function. With a value of 2 this led to horrible performance. Any clues as to why this might be?

Maybe one solution for a better performing drum sampler would be if all the samples would be stored to one .aiff file and then different keys would just read different points in one file? Though, this would require a player that can start playing from any position in a file. Just a thought.

Best,
Miro
 
So far so good with testing the WaveplayerEx for my project. I have managed to make a drum sampler that can be played quite reliably. I was testing it really hard and smashing a lot of keys on my keyboard and I'm getting some clicks still. To solve this, I tried to allocate more memory for the players with the static addMemoryForRead(mult) function. With a value of 2 this led to horrible performance. Any clues as to why this might be?

Maybe one solution for a better performing drum sampler would be if all the samples would be stored to one .aiff file and then different keys would just read different points in one file? Though, this would require a player that can start playing from any position in a file. Just a thought.

Best,
Miro

And I have finally managed to solve the source every last click and pop that was still happening. I am powering some speakers and a 5W amp from the same source as the Teensy and the USB host has some trouble handling my midi keyboard while I'm driving the speakers with high power. So, nothing to do with the WavePlayer library, but rather the USB-Host connection.

Best,
Miro
 
Hello...over a year later... What's the status of this library/object? I don't see any AudioPlayWav or PlayWavEx objects in the Audio System Gui. How do I utilize this object?

What I'm most interested in is "simply" the ability to play audio starting from a specified location so I can implement "forward" or "reverse" then play an audio stream. I'm just looking for simple tape transport control ability with Teensy.

And thanks for all the hard work you've done!
 
Hello...over a year later... What's the status of this library/object? I don't see any AudioPlayWav or PlayWavEx objects in the Audio System Gui. How do I utilize this object?

What I'm most interested in is "simply" the ability to play audio starting from a specified location so I can implement "forward" or "reverse" then play an audio stream. I'm just looking for simple tape transport control ability with Teensy.

And thanks for all the hard work you've done!

As Paul said - still a few weeks :rolleyes:
 
But ask h4yn0nnym0u5e - I think he has an alternate approach which works well.

Thanks @Mcu32!

Yes, I do like to plug it … see https://forum.pjrc.com/threads/70963-Yet-Another-File-Player-(and-recorder). Probably not quite what @some_clever_name wants, my library doesn’t do any speeds apart from 1x.

I also did some work on @Moo’s TeensyVariablePlayback, which does have variable speed, looping and so on. I did a similar approach but within his framework, it’s necessarily a bit less efficient because of the better flexibility but might serve. See https://forum.pjrc.com/threads/67613-changing-pitch-of-audio-samples-TeensyVariablePlayback-library - my latest branch commit is linked in post #80. The original requester seems to have lost interest, possibly because they couldn’t follow the Forum Rule and provide simple programs to reproduce issues they said they had…

If either of those is useful, but you have problems, please post on the relevant thread, not this one. Future seekers of wisdom will thank you.
 
Back
Top