teragonaudio / MrsWatson

A command-line VST plugin host
http://teragonaudio.com/MrsWatson.html
Other
485 stars 101 forks source link

Problems with delay compensation #201

Open Hecot opened 9 years ago

Hecot commented 9 years ago

Hi there!

I've tried to run MrsWatson - unfortunaltly it's not working. MrsWatson works fine with local DLLs but everytime I want to use a DLL that requires the support from the powercore MrsWatson crashes!

Here are her "last words":

C:\Users\Joerg\Desktop>mrswatson -p C:\Users\Joerg\Desktop\tubifex.dll -i C:\use
rs\joerg\desktop\musik.wav -o c:\users\joerg\desktop\musik-out.wav --realtime
- 00000000 000000 MrsWatson version 0.9.8 initialized, build 20150122
- 00000000 000000 Setting 2 channels
- 00000000 000000 Setting sample rate to 44100Hz
- 00000000 000000 Plugin 'C:\Users\Joerg\Desktop\tubifex.dll' is of type VST2.x
- 00000000 000000 Opening VST2.x plugin 'C:\Users\Joerg\Desktop\tubifex.dll'
W 00000000 001107 Call to deprecated function 'audioMasterNeedIdle' made by plug
in 'Vnix'
W 00000000 001107 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001107 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001107 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001107 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001107 Call to deprecated function 'audioMasterNeedIdle' made by plug
in 'Vnix'
W 00000000 001107 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001107 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001107 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001123 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001123 Call to deprecated function 'audioMasterNeedIdle' made by plug
in 'Vnix'
W 00000000 001123 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001123 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001123 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001123 Call to deprecated function 'audioMasterPinConnected' made by
plugin 'Vnix'
W 00000000 001139 Call to deprecated function 'audioMasterNeedIdle' made by plug
in 'Vnix'
W 00000000 001139 Call to deprecated function 'audioMasterNeedIdle' made by plug
in 'Vnix'
W 00000000 001139 Call to deprecated function 'audioMasterNeedIdle' made by plug
in 'Vnix'
- 00000000 001139 Starting processing input source
W 00001024 001201 Short write occurred while writing samples
INTERNAL ERROR: framesProcessed (1539) != getAudioClock()->currentFrame (1536)
  This should not have happened. Please take a minute to report a bug.
  Support website: https://github.com/teragonaudio/mrswatson/issues
  Support email: support@teragonaudio.com
INTERNAL ERROR: framesProcessed (2051) != getAudioClock()->currentFrame (2048)
  This should not have happened. Please take a minute to report a bug.
  Support website: https://github.com/teragonaudio/mrswatson/issues
  Support email: support@teragonaudio.com
INTERNAL ERROR: framesProcessed (2563) != getAudioClock()->currentFrame (2560)
  This should not have happened. Please take a minute to report a bug.
  Support website: https://github.com/teragonaudio/mrswatson/issues
  Support email: support@teragonaudio.com
INTERNAL ERROR: framesProcessed (3075) != getAudioClock()->currentFrame (3072)
  This should not have happened. Please take a minute to report a bug.
  Support website: https://github.com/teragonaudio/mrswatson/issues
  Support email: support@teragonaudio.com

Any Idea???

nikreiman commented 9 years ago

The internal error shown is a known issue, but shouldn't effect the program or cause it to crash. However, I'm curious to know if the short write still occurs when using an output source like PCM (just use -o out.pcm instead). This could be related to the new audiofile support.

It seems that the crash occurs sometime after the first few blocks have been processed. Unfortunately, without a stacktrace it is almost impossible to know what happened. I did a bit of searching around, and it seems that if you install the windows debugging tools and run the program through windbg or procdump (see http://stackoverflow.com/a/24209279/14302 ), then you can get a stacktrace.

This is probably a bit more work than should be needed though, I will try to integrate crashrpt (https://code.google.com/p/crashrpt/) in MrsWatson instead. I have created a separate issue for this, see #204.

Hecot commented 9 years ago

Thanks for the feedback and spending your time on improving this great program!!

First of all I have to confess that I was wrong with my statement that MrsWatson is crashing – in fact it “only” produces a very large amount of errors messages so I’ve canceled it after a while without let it run through. When I let it run through it produces a file with the VST effect included but unfortunately the amount of samples in the output file is different!

When looking into the output file there is a forward time shift of about 950 samples.

mrswatson_shift

I already had a look at your sources and I found the way you handle the Plug-In latency is very complicated by moving the pointer by the amount of samples from the latency. I’m pretty sure that this is the point where something will be messed up after a few cycles. Wouldn’t it be easier to process the complete file first and in a second step cut of the latency at the beginning from the finished file!??

All the best to you and happy bug hunting!

Hecot commented 9 years ago

I’ve tried to change the output file to PCM and there are no more error messages coming up!!!

Unfortunately I cannot check the PCM file as import to my program fails – I’ve tried to convert with SOX but it says: “Riff header not found” … ?

But I like to give you more precise information to help you finding the bug: mrswatson_shift_burst

My Plug-In got a latency of 450 samples when read back the plug-in info. The samples in the output Wav-file are shifted 961 samples forward! The file length of the processed Wav-file is 511 samples shorter than the original! mrswatson_filelenght

Hope this help - have a nice Easter!

nikreiman commented 9 years ago

It looks like here the problem is with audiofile WAVE output (well, probably not the audiofile library itself, but rather how MW uses it). Otherwise, my only guess would be that plugin delay compensation is not working correctly in 0.9.8.

jarl-dk commented 9 years ago

I am no longer working with sound files, i.e. MW. However, @nikreiman , if you dig deeper and really suspect that the delay compensation is buggy let me know, I may learn something, I may help with something.

jarl-dk commented 9 years ago

@nikreiman : I believe the buffer delay compensation has been broken since 6d0a28d98ec0ccd9de0125bf923da7b9a382723f

It is correct that that the program cli option is no longer necessary. But the commit destroys correct buffer delay compensation.

The only lines that should have been removed from MrsWatson.c was https://github.com/teragonaudio/MrsWatson/blob/b7886b5a69e32106e6d3fbb88b5fd60a4557e51e/source/MrsWatson.c#L498-L501

All the other logic is still necessary to "automatically" compute tail time (buffer delay compensation) which is then removed at the end.

@nikreiman : Do you want me to make a branch to show what I mean?

jarl-dk commented 9 years ago

@nikreiman: You should introduce a regression test for buffer delay compensation based on the code at b599756 (where I believe it works). From there on you can do a git bisect. I am pretty confident that it will point at 6d0a28d as the first bad commit.

nikreiman commented 9 years ago

@jarl-dk yep, my thoughts exactly. I had a feeling that I had broken delay compensation in 0.9.8, which is possible since as you noted there are no integration or unit tests for this feature. I will introduce tests and fix the bug; this is my mess so I should clean it up. :)

jarl-dk commented 9 years ago

@nikreiman : Let me know if you need help or code review...

nikreiman commented 9 years ago

@jarl-dk thanks for the offer, I will probably ping you for review when I have a patch ready.

fefanto commented 7 years ago

Hi there @jarl-dk @nikreiman. Don't know if this is still relevant, but I recently forked and modified MrsWatson in order to have DelayCompensation "neutralized", as well as having the output file exactly the same length of the input file. code is here : https://github.com/fefanto/MrsWatson all I did was adding a "validSamples" field to the sample buffer object, that is updated accordingly to plugin latency (at first read) and to required samples for aligning output to input (at last read).

ghost commented 5 years ago

Encountered the same issue, with the latest master image

bafonso commented 4 years ago

I just ran some audio through iZotope's Vinyl and noticed the shift (I got a lot of framesProcessed warnings). I don't believe @fefanto changes ever got merged back to base code. I am unfortunately using OSX (or linux) so I will try to bring in those changes but I also notice that @fefanto switched to VST3 SDK that I do not know if it will have an impact.