Author Topic: Sample Frequency Settings (Physics Question)  (Read 399 times)

Offline vantigo

  • Shy artist
  • Posts: 1
  • Operating System: Windows 10
Sample Frequency Settings (Physics Question)
« on: September 17, 2016, 00:16:02 »
I'm pretty new to audio, so I'm still trying to understand some basics. I'll probably get some things wrong here. I'd appreciate any corrections or links to places to find more info.

One thing is frequency. Higher frequency means more vibrations per second which means a higher pitched sound. I've seen this illustrated this way:



I've been going through some OpenMPT tutorials and came across instructions to make custom samples. I created a new sample with 16 sample points. I set the Freq. (Hz) to 7040 in order to get an A4 (440hz * 16 samples). I drew a curve and played it. As expected, an external tuning device registered 440hz.



But here is where I get confused. Reasoning that more curves in the same space should make a higher pitched noise, I drew more curves in the same 16 sample points and left the Freq. setting at 7040.



I played the sample and my tuning device registered the same 440hz. Why was the output the same frequency? Isn't this a perfect example of more vibrations per second?

From a technical standpoint, I can understand this. Just be sure to set the Freq. using the desired frequency * number of samples. But I'd love to have a better understanding of just what is going on here, really.

Is OpenMPT doing extra calculations to keep things in tune? Does it have to do with .wav format? I know that Freq. corresponds with a .wav file's bitrate settings. Is it because the sample is so simple in the first place?

Any insight would be appreciated, as would any links to good technical documents on the subject.

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 6,114
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 7 x64
Re: Sample Frequency Settings (Physics Question)
« Reply #1 on: September 17, 2016, 00:24:26 »
Welcome to the OpenMPT forums.
To put it simply, the extra cycles you added are not perfect, so the periodicity of your sample is still 16, and the fundamental frequency is still 440 Hz. Try looking at your sample in a spectrum analyzer (e.g. Voxengo SPAN) to see that indeed, the 440 Hz fundamental frequency is still there (although maybe not as strong as in the original sample, because there are now many overtones). Only if your sample loop had a perfect period shorter than 16 (e.g. by setting each sample point to alternating values, so the period would be 2) this could go away. The physics of extremely short samples can be funny at times.
There are a couple of other issues also contributing to the effect (but are not responsible for it in the first place), such as resampling - your 7040 Hz sample is of course not played at a sampling rate of 7040 Hz by your soundcard, but it's first upsampled to typically 44 or 48 kHz in OpenMPT, which adds its own artefacts that may add to the observed effect. The best setup to experiment with is a sample that already has a sample rate of 44 or 48 kHz.
« Last Edit: September 17, 2016, 00:28:21 by Saga Musix »
ยป No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.