View Issue Details

IDProjectCategoryView StatusLast Update
0000439OpenMPTPlugins / VSTpublic2013-10-14 03:56
ReporterSpatialAnomaly Assigned Tomanx  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Platformx64OSWindowsOS Version8
Product VersionOpenMPT 1.22.05.00 (upgrade first) 
Target VersionOpenMPT 1.22.06.00 (upgrade first)Fixed in VersionOpenMPT 1.22.06.00 (upgrade first) 
Summary0000439: Sample Rate and other Mixer Settings are not explicity set from the Tracker Settings on the SndFile object during initialization
Description

The CSoundFile::m_MixerSettings object is using default values instead of the ones specified in TrackerSettings::m_MixerSettings. This is only a problem when using a sample rate <> 44100 as VSTIs are initialized using the default sample rate of 44100 instead of the one specified in the Tracker Settings used for playback.

This can cause some VSTIs to sound out of tune (e.g. ZynAddSubSynFX VST with a String Samples) when using sample rates other than 44100 in sound card tab of the settings dialog.

Steps To Reproduce
  1. Launch OpenMPT
  2. Make sure ZynAddSubSynFX VST is added as plugin (see http://zynaddsubfx.pastnotecut.org/ZynAddSubFX-VDX_VST-2.4.1.496beta.zip)
  3. Check that the sample rate in the OpenMPT sound card settings is set to 44100
  4. Open the attached test module file
  5. Play the song, and note the two instruments are in tune.
  6. Change the sample rate in the OpenMPT Settings dialog to 48000 and click OK.
    6 Play the song. Notice the two samples are now out of tune.
  7. Set the sample rate back to 44100 the in Settings dialog and click OK.
  8. Play the song. Notice the two samples are now back in tune.
Additional Information

From inspecting/debugging the code I've confirmed that the sample rate in the CSoundFile::m_MixerSettings object is always 44100 regardless of the sound card settings in the tracker (i.e. it is never updated to 48000). Thus when the VST plugins are initialized they will always use the 44100 sample rate.

POTENTIAL FIX:
Explicitly set the CSoundFile::m_MixerSettings to the TrackerSettings::m_MixerSettings in the ModDoc constructor:

i.e. add the following line near the end of the constructor:

m_SndFile.SetMixerSettings(TrackerSettings::Instance().m_MixerSettings);
TagsNo tags attached.
Attached Files
Sample Rate Test.zip (61,227 bytes)
Has the bug occurred in previous versions?
Tested code revision (in case you know it)

Activities

Saga Musix

Saga Musix

2013-10-04 19:15

administrator   ~0001342

I cannot confirm the problem; However, as far as I can tell from other plugins, OpenMPT will set the correct sample rate for every plugin (in OnResume) after it has been changed. There are plugins which have trouble with that, the version of Zyn that I tried doesn't seem to have the problem. Basically, the same problem should occour when loading the plugin e.g. into Renoise and changing the sample rate there.

manx

manx

2013-10-04 20:33

administrator   ~0001343

I can reproduce the problem with your provided testcase.
The problem in fact seems, as Saga Musix suggests, that this version of ZynAddSubFX seems to ignore updating of the sample rate.
OpenMPT updates the CSoundFile and VST plugin state to the current settings when sound playback is actually started (which in turn gets called when settings get changed, where basically output is stopped and directly started again). The relevant call chain here is: CMainFrame::PlayMod -> CMainFrame::UpdateAudioParameters (to update CSoundFile state), CMainFrame::PlayMod -> CSoundFile::ResumePlugins -> CVstPlugin::Resume -> CVstPlugin::Dispatch(effSetSampleRate, ...) (to update VST plugin state).
As there are some plugins which have trouble with changing the samplerate, I have commited a fix similar to what you suggested: "CMainFrame::UpdateAudioParameters(m_SndFile, true);" at the end of CModDoc::CModDoc(). (see http://sourceforge.net/p/modplug/code/2820 )
This should at least initialize VST plugins to the currently selected sample rate. It does, however, not fix the case of changing the sample rate after a plugin has already been initialized (which is, as far as i can see, really a bug with the respective plugin and not something OpenMPT itself could address). The only workaround i can suggest here, is: When changing your sample rate setting and a plugin misbehaves, close your file and reopen it after changing the settings so it can catch up the new sample rate during first initialization.

SpatialAnomaly

SpatialAnomaly

2013-10-07 04:00

reporter   ~0001344

Thanks guys, for looking at this so quickly. Manx, the workaround you suggests seems very reasonable to me.

Really appreciate all you are doing to keep making this great software even better.

Saga Musix

Saga Musix

2013-10-09 10:13

administrator   ~0001346

Guess we can close this one then?

SpatialAnomaly

SpatialAnomaly

2013-10-11 10:53

reporter   ~0001347

Yes, feel free to mark it closed.

Issue History

Date Modified Username Field Change
2013-10-04 08:15 SpatialAnomaly New Issue
2013-10-04 08:15 SpatialAnomaly File Added: Sample Rate Test.zip
2013-10-04 19:15 Saga Musix Note Added: 0001342
2013-10-04 20:33 manx Note Added: 0001343
2013-10-07 04:00 SpatialAnomaly Note Added: 0001344
2013-10-09 10:13 Saga Musix Note Added: 0001346
2013-10-11 10:53 SpatialAnomaly Note Added: 0001347
2013-10-11 10:54 Saga Musix Status new => resolved
2013-10-11 10:54 Saga Musix Resolution open => fixed
2013-10-11 10:54 Saga Musix Fixed in Version => OpenMPT 1.22.06.00 (upgrade first)
2013-10-11 10:54 Saga Musix Target Version => OpenMPT 1.22.06.00 (upgrade first)
2013-10-11 16:29 Saga Musix Assigned To => manx
2016-11-20 17:48 Saga Musix Category VST => Plugins (VST)
2016-11-20 17:48 Saga Musix Category Plugins (VST) => Plugins / VST