GrandOrgue resampling and repitching algorithms #1559
Replies: 2 comments 1 reply
-
As nobody has commented on this and as I have been recently retuning samples myself here are some thoughts: Is it better to have an out of tune organ than one tuned perfectly. This is debatable - every real organ is always going to be a bit out of tune but does anybody listening to it notice or care. It is possible to tune a virtual organ almost to perfection - but does it sound better? As we all know there are many hundreds of different tuning scales so who is to say which one is perfect. The answer - none of them is perfect, if one was perfect we would always use it and discard the others. Organ notes rely on harmonics to make a musical sound - working with sine waves is good for demonstrations and making eye catching comparisons but does this have any value in the real world? What do the pictures mean? The only real way to know would be to listen to the sound produced. I have listened to notes while they are being tuned and have not noticed any obvious change as the tuning is altered. As I understand it notes are tuned by making fine adjustments to the sample rate - the original digitally sampled waveform itself is not altered. Perhaps somebody could explain how this is done. Is the filtered original wave re-sampled or is the re-sampling done on the original digital wave (i.e. before filtering)? Both methods would slightly degrade the waveform and this is probably what the above pictures show. Thus my conclusion would be that it is better to make sure the note is in tune before recording the note. csw900 |
Beta Was this translation helpful? Give feedback.
-
The linear inerpolation was added by Martin and the polyphase by Nick (which, by profession, is qualified to judge any re-sampling much better than any of the rest of us other developers). I'm personally pretty certain that no other external library will out of the box provide better (== better speed and at the same time better sound quality) results than what's already existing. Not to mention that there's the additional complexity added by the lossless compression algorithm to take into account. If one would be ready to sacrifice one or the other, things might be different... The sound degradation (distortion) resulting from any kind of re-sampling is a trade off we'll have to accept to a certain degree to gain the features we have available at the moment. Feel free to experiment and add other implementations yourself and compare what the results of it would be to the current implementation (use both practical experience, visualization, and for instance the raw perftest data polyphony). But don't expect any to be better in all kind of contexts. My own aural, and highly personal, experience is that linear interpolation performs better on low pitched samples whereas the polyphase performs better on high pitch samples, if only sound quality is factored in. As soon as performance - in terms of speed - (or available polyphony) is factored in, the picture becomes much more complicated than what the articles on Sonus Paradisi even begin to touch on. Reducing the depencencies on external libraries can also sometimes be a very good approach, when there's absolutely no (absolute) benefits from using them! Mainly, speed and indeed less maintanence can sometimes be huge benefits from not using other libraries. However, the benefits from actually using third parties code can be that you don't have to research it yourself... So, as always, it's a trade off... |
Beta Was this translation helpful? Give feedback.
-
I recently read the on the Sonus Paradisi blog about re-pitching or resampling issues in early versions of Hauptwerk being dramatically improved in later versions:
https://www.sonusparadisi.cz/en/blog/audio-improvements-in-hauptwerk-6-and-hauptwerk-7/
I thought I would make an attempt to produce similar data for Grandorgue. So I created an organ which produces a 2 kHz sine wave at 24 bit resolution, 48 kHz sample rate, and amplitude of 50% of full scale. I used a program called Friture (freely available as an appimage) to take the FFT and the 2d spectrogram. Since I cannot use a slider to dynamically change the pitch as did Sonus Paradisi, I took data at no pitch shift, a -10 cent pitch shift and +10 cent pitch shift using the Organ Settings dialog. I did this for both the linear and polyphase interpolation options of GrandOrgue.. GrandOrgue is sending data to JackAudio and to Friture. Here are the results:
No Pitch Shift:
+10 cent Pitch shift linear interpolation
in this case we see distortion (probably due to aliasing about 55 db below the fundamental. The largest distortion is at 1.78kHz which is not harmonically related to the fundamental of 2 kHz
+10 cent shift, polyphase interpolation.
Here we see fewer components in the distortion and at slightly different frequencies, but the largest distortion component is 2dB larger than with linear interpolation.
With a -10 cent pitch shift, we see similar results, except that the largest component of distortion is now at a higher frequency than our test tone (polyphase interpolation shown:
As near as I can determine from the GrandOrgue source code the re-pitching/ resampling algorithm is home grown code, rather than relying on one of the available resampling libraries which appear to have much better performance. I’m wondering if there is any interest in pursuing the use of an open source library for pitch shifting.
http://src.infinitewave.ca/ gives a comparison of many different resamplers. ZitaResampler and Secret Rabbit Code (libsamplerate) appear to be good candidates with understandable documentation.
Beta Was this translation helpful? Give feedback.
All reactions