This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#10590 - Aliasing when playing MIDI files on iPod 5G
|
DetailsStarting from the daily build from mid August (can't exactly say when, because I don't play MIDIs so often), the MIDI playback on my iPod 5G 30GB sounds distorted, especially the Piano sample.
It sounds as if the higher frequencies are chopped of and instead replaced by "alias frequencies". Maybe something has been messed up in the mixing routine concerning decimation filter / interpolation. I am using the original patchset provided here at rockbox.org. Maybe somebody could check this - thank you! Keep up the great work! |
This task depends upon
All versions starting from 20635 play MIDI files in very bad quality, with aliasing frequencies, probably due to downsampling to 22 kHz without interpolation / decimation filter.
I suppose to change the MIDI plugin to *always* use 44.1 kHz sample frequency / mixing frequency on iPod, for best playback quality. iPod 5G plays MIDIs just fine at this frequency since the buffer handling has been optimized some builds before 3.2 (if I remember correctly right now). Okay, you shouldn't play files with a whole symphony orchestra playing "tutti" over several measures or so - but it works well and it is much better than distorted, aliased 22 kHz playback with maybe a longer buffer instead.
Btw. Why has been 22 kHz Playback support been added anyway? What is its use besides the midi plugin?
Maybe the MIDI plugin could get added an option to choose which mixing frequency to be used? And if 22 kHz is selected, a proper interpolation should be done!
Anyway, thanks for the information! For now, I'll stick back to an old version without 22kHz playback, until there is a solution to this problem. Keep up the *great* work!
Best regards, kzuse
Wavetable MIDI sound output always results in mixing different instrument samples together, which is done at one specific mixing rate. For me on my iPod 5G, the 44.1 kHz rate sounded much, much better. I have some piano tunes that introduce a strange, ringing distortion in every note. This sounds very bad to me. I would prefer an option to choose 44.1 kHz sample rate for MIDI playback manually, even if the player supports 22.05kHz. There has not even to be a GUI to this option, maybe just read out a setting "midi.ini" file in the .rock plugins folder or so.
This would be great.... :-)
This "bug" is however a trade off between better sounding higher samplerate but with more horribly sounding buffer underrun skips or lower worse sounding sample rate but fewer skips. The midi plugin is in need of serious optimization to be able to play most files at 44.1kHz on pp based players like the ipod video so i'm reluctant to change this, players with faster chips like the nano2g could still use 44.1kHz even if the hardware can go lower.
I don't know what is causing it, whether it is the MIDI plugin or it is the 22kHz driver or core capability - I just know that it sounds horrible and definitely worse than occasional skips.
What about my idea to implement an option in to the MIDI plugin, whether to always use 44.1 kHz (which would be my favorite setting), or to use 22kHz if available on the device. That would serve everybody!!! :-)
Best regards, kzuse
But still, there is a HEAVY aliasing in playback which was not there back then when 44.1kHz were used for MIDI. Maybe it is the iPod hardware that doesn't apply an imaging filter for 22.05 kHz.
Btw, I could not find that wirh 22.05kHz there is less skipping or left-out notes. I find we should go back to 44.1 kHz on ipod for MIDI as it brings much better sound and does not significantly "skip" more in MIDI. I will keep watching this issue.
best regards, kzuse
#define SAMPLE_RATE SAMPR_44
This is better for iPod, believe me, 22 kHz sounds crappy on it...
I recommend everybody of you, who also finds this disturbing, to do so. It's the easiest way to get rid of it.
So, we should either go back to 44100 Hz (and stop aliasing) or increase MAX_VOICES for PP-targets which do use sampling rates <44100 Hz.
But, as I mentioned above, I changed midiutil.h to always use 44 kHz, as in former times, and it is such a relief not to hear those aliasing frequencies and have an overall better sound quality, that I would really recommend to go back to 44 kHz by default.
Just my EUR 0,02... :-)
- Use 22 kHz if supported, except for iPod Video (produces aliasing artifiacts)
- Use up to 20 voices for PP in case of 44.1 kHz sampling rate (beyond that I experience buffer misses)
- Move some data to IRAM
- Introduce panSample macro which avoids multiplication and shifts for balanced panning (pan = 64)
- Change sample calculation to int16 instead of int32. This is slower but correct.
1) Testing some more files on my h300 i hear the ringing or aliasing on some files but not on the ones i used for testing before :/
2) The conditional pan multiply doesn't bring any speedup for cf
3) The patch slows down midi by ~10% on cf
While i agree that correctness is more important than speed i'd like to try out doing it correctly while keeping the sample buffer 32 bits and will hopefully find the time for that in the near future.
Edit: If we want to go all-out we could mimic what the ape codec does, since it also deals with packed 16-bit values for cf and >= ARMv5 while keeping the 16 bit samples as 32 bit for ARMv4 as the unpacking and repacking cost more than the gain from the reduced mem usage there.
Also something with the pan==64 case looks fishy to me, *64 should equal << 6 but the samples were shifted >> 7 and << 9 which would equal a shift of >> 1 for both but you don't shif them at all.
FS#10086/ r20635. I don't see any problems which would cause aliasing. The relevant part of the datasheet is this:>The WM8758B filter characteristics for the ADCs and the DACs are set using the SR register bits.
>The cutoffs for the digital filters and the ALC attack/decay times stated are determined using these
>values and assume a 256fs master clock rate.
>If a sample rate that is not explicitly supported by the SR register settings is required then the
>closest SR value to that sample rate should be chosen, the filter characteristics and the ALC attack,
>decay and hold times will scale appropriately.
You can see the ADDCTRL_SR_ defines in firmware/export/wm8758.h and their use in firmware/drivers/wm8758.c. Sample rate calculations are in a spreadsheet at https://docs.google.com/spreadsheet/ccc?key=0AsEpnuZKewlIcmhFRXYtN0RVQTMtSVllWGUyeUI2aUE&hl=en_US#gid=0
You could try changing the ADDCTR_SR_ values in freq_setups, using the value below the frequency instead of the closest value which is above the frequency. I'm attaching a patch which does this for 22 kHz. I'm not sure if it actually helps. Even if it does help, that doesn't mean there's a driver error, because it could cover up aliasing in the audio being played. Doom uses 11 kHz. Is there aliasing there?
Now with the new build, aliasing/ringing is there again! I actually thought, due to the comments you've added some months ago, that it has been fixed by no longer using 22kHz on iPod targets?
Or did I get that wrong, and the patch(es) you've attached above didn't make it into the normal trunk?
Is there a chance this could be done? So iPod Video users don't always have to patch for themselves for every new release? :)
Thanks a lot!