Sign in

sample tuning is wrong in wave file import/export

  • SC 69 0
    In the WAV file "smpl" sub-chunk, there are two fields that store sample tuning information:
    • dwMIDIUnityNote - This is the MIDI note number or "root key" for the sample.
    • dwMIDIPitchFraction - Specifies the fraction of a semitone up from the sample's MIDI note. Only positive values can be stored in this field, so the note can only be tuned sharp. If you want to represent a negative fine tuning, you must add 1 to the root key (which lowers the sample playback pitch by 1 semitone) and add 100 to the negative tuning value to achieve the correct positive value. This conversion can be reversed on WAV import for any fine tuning value larger than 50, effectively providing a fine tune range of -49 to 50 cents for each sample.

    Polyphone reads and writes these fields when importing and exporting WAV files. However, Polyphone appears to be doing this in a somewhat inverted manner, assuming I am not misunderstanding how this is supposed to work.

    Steps to reproduce:
    1. Choose or edit a sample in Polyphone to specify a root key and fine tune amount. Make sure this is done at the sample level, not instrument level. For this example, I have chosen MIDI note 70 and a fine tune of +24 cents.
    2. Export the WAV file.
    3. Open the exported WAV file in a hex editor.

    Result: the sampler metadata in the WAV file shows MIDI note 69 and fine tune 76, but it should be MIDI note 70 and fine tune 24. The value of 76 appears to be the result of adding 100 to -24, which should not happen in this case.

    Note: in the hex editor, the MIDI note is stored at offset 003A (hex value: 45, converted to decimal: 69), and the fine tuning is a little endian int at 003E (hex value: C28F5C29, converted to decimal: 3264175145). So to convert to cents: 3264175145 / 2147483648 * 50 = 76.

    If I repeat the same steps above, but change the tuning to -24 cents, the exported WAV file shows MIDI note 70 and fine tune 24, but it should be MIDI note 71 and fine tune 76 (adding 100 to -24 is correct here).
  • 409 0
    Message from Davy on
    The value displayed at the sample level is the correction that will be applied to the sample so that it matches exactly the root key.
    This is thus the opposite of what is written in a wav file. If a sample is a bit sharp, the description in the wav file shows a positive value but we need to apply a negative correction to compensate.

    Your description is thus correct and everything is fine

Sign in or register to take part in discussions.

Polyphone needs you!

Polyphone is free but there are costs associated with its website and development. A small donation will help a lot.

Donate
Learn the basics Try a tutorial
Scroll to
top