View Issue Details

IDProjectCategoryView StatusLast Update
0000019OpenMPTUser Interfacepublic2014-02-13 08:45
ReporterLPChip Assigned ToSaga Musix  
PrioritylowSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformPCOSWindowsOS Version7 x64 ultimate
Product VersionOpenMPT 1.18.03.00 (upgrade first) 
Target VersionOpenMPT 1.22.06.00 (upgrade first)Fixed in VersionOpenMPT 1.22.06.00 (upgrade first) 
Summary0000019: Soundbuffer with plugins doesn't get cleared when doing a wave export
Description

If you have a plugin in your song that has some kind of playback buffer (like an echo or reverb) or VSTi's that has one build in, or possibly even have a sustain release set, the sound can be carried continiously in the buffer until you replay the song or do an export to wave.

As result, you will hear what was previously playing when you stopped the song, which can be a pain to get in a wave export.

Steps To Reproduce

Create a song, add an echo plugin to it and set it so that it has atleast a 2 second tail. Add some silence in the beginning of the song and then play a note with this echo attached.

Once you hear the note, immediatelly stop the playback by hitting the stop button (or F8).

You can now wait until forever and it will keep the data in the buffer.

Now, if you play the song from the start, where you had the silence, you will now hear what was previously in the buffer.

Additional Information

Workaround:
In order to be able to clear the buffer normally, after you stopped the song at that point, go to the instrument tab and play a short note. the soundbuffer will be opened again, and it will play everything in the queue. Additionally it will keep the buffer open so the sound can wear out normally. Once there is no sound, you can do a good export to wav.

Solving and issues:
Obviously, it would be best if you can just keep the soundbuffer open, like it happens when you play an instrument in the instrument tab. Problem is that OpenMPT is known for not having the sound buffer open all the time in case you want to switch to another program. I think it would be best to close the soundbuffer if OpenMPT loses focus, and reopen when it gains focus. This in conjunction with the kill notes button should fix everything. Perhaps add a double click the stop button to just close the buffer as if OpenMPT lost focus could be a panic button of some sort.

TagsNo tags attached.
Has the bug occurred in previous versions?yes. Bug was first discovered in .48
Tested code revision (in case you know it)

Activities

jmkz

jmkz

2011-02-03 01:39

reporter   ~0000052

Well, I am on pro of this, but at some point is useful. For example, if you make a loop song you probably want to hear the "fading" of an echo or reverb. I think that this is better if kept as a choice.

LPChip

LPChip

2011-02-03 08:41

manager   ~0000053

jmkz, if you would add an empty pattern after the one you have with the echo/reverb, it should normally be present in the export.

I doubt you would want to move this echo/reverb to the beginning of the song? (which is what this bug is about)

404notfound

404notfound

2011-02-05 09:20

reporter   ~0000054

Maybe turn this bug in a selectable feature which allows you to wrap the rendered song/pattern's tail.

LPChip

LPChip

2011-02-05 11:11

manager   ~0000055

Its not about the rendering tail. its about the start of the rendering which still has stuff in it thats in the soundbuffer, so the start of the song doesn't sound like its supposed to be. Can have an annoying click and more in it, due to the soundbuffer not properly cleared.

Saga Musix

Saga Musix

2012-07-04 00:34

administrator   ~0000778

I just want to add a note why this happens and why it's hard to fix (and thus will probably never be fixed).

Plugins can be turned on and off from the plugin host via the "effMainsChanged" opcode. The VST "standard" requires plugins to clear any buffers they may be using internally when they are switched on this way. OpenMPT calls this opcode whenever it stops or resumes playback, and there are many plugins which wipe their delay / reverb / etc. buffers when they are requested to do so.

As you have noticed, not all plugins do this, and there is no perfect way to handle them. You could theoretically render a bit of silence and check if the output of the plugin is also silence. However this would fail with e.g. echo plugins that have a long delay between echos (this delay will obviously be silent). Obviously this is a bug in the plugins and not OpenMPT. Other hosts simply "fix" this by never closing their audio buffer, and you have to do exactly the same thing as in OpenMPT before doing any audio export in those hosts: Wait until the effect tail has finished playing. This is the only proper way I can see to fix this issue: Never closing OpenMPT's audio output. Of course this should be an option if it is ever implemented.

LPChip

LPChip

2012-07-04 07:44

manager   ~0000784

I understand. Would it be possible to check if the audio buffer has data in it before the wave export begins, and issue a warning to the user?

For example, it opens the audiostream and sees if there's anything but silence directly at the beginning of the stream. This wouldn't be perfect for echos that could be mute, but its better than nothing.

If it does, a message pops up, and the wave export is aborted.

The message could be: "OpenMPT noticed that some plugins still play sounds. This can lead to unwanted sounds at the beginning of your song. You can clear this by playing an instrument from the instruments tab and wait until you hear silence, then export to wave again."

Saga Musix

Saga Musix

2012-07-04 10:27

administrator   ~0000785

There is no audio buffer "before" wave export. The only way to check this would be to render a buffer of silence as described before and check if the output it also silence. However this would fail for the reasons described above, and it could even result in an infinite loop for plugins that always emit some audio (i.e. they are never silent)

<blockquote>You can clear this by playing an instrument from the instruments tab and wait until you hear silence</blockquote>

Telling the user to do something that the application itself could do is one of the worst violations of usability that you could do.

Saga Musix

Saga Musix

2013-10-23 16:22

administrator   ~0001355

I've added an experimental feature to WAV export which will not completely solve the problem (as said before, that's technically not possible), but it helps in most cases: Use the "Clear plugin buffers before exporting" option to let OpenMPT render up to 20 seconds of silence for each plugin, so that reverb tails etc. can fade out. If the plugin has a longer effect tail and doesn't clear it, it will remain in the buffer (to prevent OpenMPT from waiting a potentially infinite amount of time for plugins to render silence).
The new feature can be tested at http://sagagames.de/stuff/mptrack.exe as always.

LPChip

LPChip

2013-10-23 21:16

manager   ~0001357

Confirmed to work perfectly :)

The tail I'd be having will be at most 5 seconds anyway, so 20 seconds is more than enough, and it does not compromise in any delay on the wave export, so you may consider this fixed. :)

I'd love to see an option to enable this checkbox by default.

Issue History

Date Modified Username Field Change
2010-11-06 12:02 LPChip New Issue
2010-11-06 12:07 Saga Musix Status new => confirmed
2011-02-03 01:39 jmkz Note Added: 0000052
2011-02-03 08:41 LPChip Note Added: 0000053
2011-02-05 09:20 404notfound Note Added: 0000054
2011-02-05 11:11 LPChip Note Added: 0000055
2012-07-04 00:34 Saga Musix Note Added: 0000778
2012-07-04 00:34 Saga Musix Priority normal => low
2012-07-04 07:44 LPChip Note Added: 0000784
2012-07-04 10:27 Saga Musix Note Added: 0000785
2013-10-23 16:22 Saga Musix Note Added: 0001355
2013-10-23 16:22 Saga Musix Assigned To => Saga Musix
2013-10-23 16:22 Saga Musix Status confirmed => feedback
2013-10-23 16:22 Saga Musix Target Version => OpenMPT 1.22.06.00 (upgrade first)
2013-10-23 21:16 LPChip Note Added: 0001357
2013-10-23 21:16 LPChip Status feedback => assigned
2013-10-23 21:17 Saga Musix Status assigned => resolved
2013-10-23 21:17 Saga Musix Resolution open => fixed
2013-10-23 21:17 Saga Musix Fixed in Version => OpenMPT 1.22.06.00 (upgrade first)