Welcome, Guest
Username: Password: Remember me

TOPIC: sample tuning is wrong in wave file import/export

sample tuning is wrong in wave file import/export 1 year 9 months ago #1

  • S. Christian Collins
  • S. Christian Collins's Avatar
  • Offline
  • Senior Member
  • Posts: 66
  • Thank you received: 24
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).
Last Edit: 1 year 9 months ago by S. Christian Collins.
The administrator has disabled public write access.

sample tuning is wrong in wave file import/export 1 week 1 day ago #2

  • Davy
  • Davy's Avatar
  • Offline
  • Administrator
  • Organ enthusiast and creator of Polyphone
  • Posts: 397
  • Thank you received: 89
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 :-)
The administrator has disabled public write access.
Time to create page: 0.048 seconds
Cron Job Starts