Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Add a more advanced host example #10

Open
Bobo1239 opened this issue Aug 19, 2017 · 8 comments
Open

Add a more advanced host example #10

Bobo1239 opened this issue Aug 19, 2017 · 8 comments

Comments

@Bobo1239
Copy link

It took me some time to get this to work. (And I'm not sure if that's the intended usage.) Adding a host example which utilizes AudioBuffers and (Midi)Events would make this aspect of the project more approachable.

@zyvitski
Copy link
Member

Seems to be a great start at an example! It will be important to find a way to make it platform agnostic though. The most obvious approach in that case might be to have it load an example plugin and use that. The hard part would be the bundling the plugins on OS X. But if we could use the bundler script from a build.rs it could be done.

@phonkee
Copy link

phonkee commented Aug 20, 2017

Thank you for your example, I have tested it on OS X, but it segfaults.
Does anyone on OS X has the same experience?

The segfault happens on line:

    instance.process(&mut buffer);

@Bobo1239
Copy link
Author

Bobo1239 commented Aug 21, 2017

It's quite possible that my example isn't doing stuff the right way(tm) but I did test it on Windows and Linux. Which VST did you try? I've tested Pianoteq 5 and sine_synth from the examples.

edit: Some details of the error in Bobo1239/rust-vst-demo#1; I've tried the Spire VST on Windows and also get a segfault. Will try to investigate tomorrow.

@Bobo1239
Copy link
Author

After tracing what https://github.com/teragonaudio/MrsWatson is doing, I think I know the problem:

OpCode::GetTime isn't handled here and thus 0 is returned. (MrsWatson handles the opcode like this.)
But Spire expected a pointer to a VstTimeInfo (from the VST2 SDK) and tries to read a field from the struct causing the segfault.
(Dr. Memory reports UNADDRESSABLE ACCESS: reading 0x0000000000000019-0x0000000000000021 8 byte(s))

Somebody would need to clone the struct definition to Rust but I'm not sure if handling timing should be in scope of this library. (I tend to side with no but we'd then need a way to delegate that request to the library user.)

In case anybody else wants to further investigate:
I used mrswatson64 --midi-file c-scale.mid --output out.wav --plugin $PATH_TO_DLL --verbose.
MIDI file: https://my.mixtape.moe/deikbd.mid (MrsWatson only supports Type 0 MIDI files; Type 1 support is a PR)
Partial output (OpCode::GetTime is 7):

Processing audio with plugin 'Spire-1.1.dll'
Plugin 'Spr2' called host dispatcher with 7, 0, 512
Current PPQ position is 4.85451
Plugin 'Spr2' called host dispatcher with 7, 0, 1024
Plugin 'Spr2' called host dispatcher with 7, 0, 1024
Plugin 'Spire-1.1.dll' spent 3ms processing (0% effective CPU usage)
Wrote 1024 samples to PCM file

@Bobo1239
Copy link
Author

@phonkee Perhaps #32 will fix your problem.

@phonkee
Copy link

phonkee commented Dec 24, 2017

Thank you, this is awesome. I have tried other vst and it works. My actual target vst is Virus TI. I will try it in next days.
It's multi output vst that controlls Virus hardware synthesizer, I will share my experience then..

Lastly I want to thanks all people involved in this awesome project and I hope that I will be able to contribute in the future.

Thank you and Merry christmas to you all!

@piedoom
Copy link
Contributor

piedoom commented Dec 24, 2017

Merry xmas and happy holidays to you as well! Hope it works out. Feel free to join our telegram group if you'd like to get more involved.

@TailyFair
Copy link

TailyFair commented Mar 18, 2019

Host example that shows how to output to speakers real-time would be super helpful.

inikulin added a commit to inikulin/vst-rs that referenced this issue Jan 2, 2020
inikulin added a commit to inikulin/vst-rs that referenced this issue Jan 2, 2020
inikulin added a commit to inikulin/vst-rs that referenced this issue Jan 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants