Git Product home page Git Product logo

vst2's Introduction

vst2

PkgGoDev Go Report Card Test codecov

vst2 implements VST2 SDK API. It provides capabilities to build both VST2 hosts and plugins.

Installation

$ go get -u pipelined.dev/audio/vst2

Quick Start

Refer godoc documentation for example.

License

vst2 is licensed under MIT license.

vst2's People

Contributors

dudk avatar lsegal avatar martinimoe avatar robinkamps avatar ryrun avatar vsariola avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vst2's Issues

Crash on processing single-channel data with TAL-Reverb-4 on windows

The test plugin for windows (TAL-Reverb-4) is crashing when single-channel data is being processed.

Validation plan:

  • check if problem persists with other plugins (No)
  • check if problem persists with multiple channels (No)
  • check with TAL-Reverb-4 for macOS
Received opcode: HostGetCurrentProcessLevel
Received opcode: HostGetCurrentProcessLevel
Exception 0xc0000005 0x1 0x0 0x7ffea0b2b7a4
PC=0x7ffea0b2b7a4

runtime: unknown pc 0x7ffea0b2b7a4
stack: frame={sp:0x7dfae8, fp:0x0} stack=[0x0,0x7dfdc0)
00000000007df9e8:  00000000004b0706  0000000000000000
00000000007df9f8:  0000000000000000  0000000000000000
00000000007dfa08:  0000000000000000  0000000000000000
00000000007dfa18:  00000000004b043d  0000000000000000
00000000007dfa28:  0000000000000000  0000000000000000
00000000007dfa38:  0000000000000000  0000000000000000
00000000007dfa48:  0000000000000017  0000000000000000
00000000007dfa58:  00000000004b0270  0000000000000086
00000000007dfa68:  0000000000177f60  0000000000000000
00000000007dfa78:  0000000000000005  0000000000930b50
00000000007dfa88:  0000000000000017  0000000000000000
00000000007dfa98:  0000000000000000  0000000000000000
00000000007dfaa8:  00007ffe00000000  0000000000000000
00000000007dfab8:  0000000000000000  000000c000147a28
00000000007dfac8:  0000000000000000  000000c00014a020
00000000007dfad8:  000000c0001479e8  0000000000000200
00000000007dfae8: <00007ffea0a92d4a  0000000000000106
00000000007dfaf8:  00007ffed787b997  0000000000e50000
00000000007dfb08:  0000000000000000  0000000000000000
00000000007dfb18:  00007ffe00000000  0000000200000001
00000000007dfb28:  0000000000000002  0000000000000002
00000000007dfb38:  0000000000000008  00000000008b7dc0
00000000007dfb48:  0000000000171c62  000000000c00000c
00000000007dfb58:  0000000000000000  fffffffffffffffe
00000000007dfb68:  0000000000000000  000000000c00000c
00000000007dfb78:  0000000000000008  000000000000000c
00000000007dfb88:  00000000008b7d70  0000000000000000
00000000007dfb98:  00000000004e4160  0000000000000000
00000000007dfba8:  0000000000001000  0000000000000000
00000000007dfbb8:  0000000000000000  0000000000000081
00000000007dfbc8:  0000000000001010  0000000000170000
00000000007dfbd8:  00007ffed787ba3b  0000000000170000
runtime: unknown pc 0x7ffea0b2b7a4
stack: frame={sp:0x7dfae8, fp:0x0} stack=[0x0,0x7dfdc0)
00000000007df9e8:  00000000004b0706  0000000000000000
00000000007df9f8:  0000000000000000  0000000000000000
00000000007dfa08:  0000000000000000  0000000000000000
00000000007dfa18:  00000000004b043d  0000000000000000
00000000007dfa28:  0000000000000000  0000000000000000
00000000007dfa38:  0000000000000000  0000000000000000
00000000007dfa48:  0000000000000017  0000000000000000
00000000007dfa58:  00000000004b0270  0000000000000086
00000000007dfa68:  0000000000177f60  0000000000000000
00000000007dfa78:  0000000000000005  0000000000930b50
00000000007dfa88:  0000000000000017  0000000000000000
00000000007dfa98:  0000000000000000  0000000000000000
00000000007dfaa8:  00007ffe00000000  0000000000000000
00000000007dfab8:  0000000000000000  000000c000147a28
00000000007dfac8:  0000000000000000  000000c00014a020
00000000007dfad8:  000000c0001479e8  0000000000000200
00000000007dfae8: <00007ffea0a92d4a  0000000000000106
00000000007dfaf8:  00007ffed787b997  0000000000e50000
00000000007dfb08:  0000000000000000  0000000000000000
00000000007dfb18:  00007ffe00000000  0000000200000001
00000000007dfb28:  0000000000000002  0000000000000002
00000000007dfb38:  0000000000000008  00000000008b7dc0
00000000007dfb48:  0000000000171c62  000000000c00000c
00000000007dfb58:  0000000000000000  fffffffffffffffe
00000000007dfb68:  0000000000000000  000000000c00000c
00000000007dfb78:  0000000000000008  000000000000000c
00000000007dfb88:  00000000008b7d70  0000000000000000
00000000007dfb98:  00000000004e4160  0000000000000000
00000000007dfba8:  0000000000001000  0000000000000000
00000000007dfbb8:  0000000000000000  0000000000000081
00000000007dfbc8:  0000000000001010  0000000000170000
00000000007dfbd8:  00007ffed787ba3b  0000000000170000

goroutine 1 [syscall]:
pipelined.dev/vst2._Cfunc_processDouble(0x930b50, 0x20000000001, 0xc00014a020, 0xc00014a028)
        _cgo_gotypes.go:151 +0x4c
pipelined.dev/vst2.(*Plugin).ProcessDouble.func1(0xc000126360, 0xc000147ab0, 0xc000147ad8)
        C:/dev/vst2/vst2/vst2.go:184 +0x161
pipelined.dev/vst2.(*Plugin).ProcessDouble(0xc000126360, 0x1, 0x200, 0xc00014a020, 0x1, 0x1, 0x1, 0x200, 0xc00014a028, 0x1, ...)
        C:/dev/vst2/vst2/vst2.go:184 +0x46
main.main()
        C:/dev/vst2/vst2/examples/example_vst2.go:85 +0x4a1
rax     0xffffffffffffffff
rbx     0x200
rcx     0x10
rdi     0x0
rsi     0x1
rbp     0x2
rsp     0x7dfae8
r8      0xff0
r9      0x1f
r10     0x177f70
r11     0x0
r12     0x930dc0
r13     0x2
r14     0xc00014a028
r15     0x930b00
rip     0x7ffea0b2b7a4
rflags  0x10213
cs      0x33
fs      0x53
gs      0x2b
exit status 2

Handle plugGetParamDisplay correctly

Existing implementation returns constant value hardcoded in the vst2.Parameter struct. It should call a user-defined function that will return display value based on current parameter value.

Documentation upgrade: vst2 is discontinued

Since vst2 is obsolete than README looks a little bit ambiguous. The Steinberg site offers to download vst3 SDK version at the moment, so for newcomers, it's not obvious what they should do next: to download vst3, to try to find a vst2 archive etc.

Would you mind explaining this on the README page, please?

P.S. Does it make sense to use vst2 if it's discontinued? Or the naming of the project doesn't mean that it relies on the vst2 exactly?

MIDI input/output channels?

Can you create a MIDI effect plugin with only MIDI on inputs and outputs?

The demo plugin does have the default MIDI events-in input, didn't find any info on adding more and creating a MIDI output in the docs.

The idea is modifying incoming MIDI CC commands on certain channels.

Migrate to latest VST2 SDK

Version of VST 2 SDK used in this project is no more publicly available. The only way to get SDK is still thorough Steinberg Portal. They offer VST 3 SDK that still contains VST 2 SDK within.

However, new version has different header names, so code has to change.

  • migrate to VST 2 SDK from VST 3 SDK
  • update README

OS X plugin bundler

Provide CLI that would bundle compiled plugin to OS X bundle. Here is the example of bundler from rust vst2 project.

Command to compile plugin into Mach-O bundle:

go build --buildmode c-archive --tags plugin -o demoplugin.a 
clang -bundle -o demoplugin -all_load demoplugin.a

Documentation request: examples and/or getting started?

I just happened upon this project while searching for Golang / VST SDK bindings. Looks promising!

Are you at a point where it makes sense to have other people try out this package? I'm a Go developer, although I haven't worked with the VST SDK yet and I'm not educated on the common patterns. As such, a passthrough audio example like this for JACK would be really helpful.

Linux AMD64 cannot use _Ctype_longlong(flags) (value of type _Ctype_longlong) as _Ctype_long value in variable declaration

I can't build this on Linux AMD64 because of the following error:

../../../go/pkg/mod/pipelined.dev/audio/[email protected]/plugin.go:141:97: cannot use _Ctype_longlong(flags) (value of type _Ctype_longlong) as _Ctype_long value in variable declaration

Changing the given line to

return (*TimeInfo)(unsafe.Pointer(uintptr(C.callbackHost(h.callback, cp, C.int(HostGetTime), 0, C.long(flags), nil, 0))))

seems to fix the issue and it builds successfully.

go imports/module, example and opcodes

Good Evening,
thanks for you effort to bring vst to golang!

Just tried to get the example up and running, but ran into some minor problems:

var data = signal.Float64([][]float64{
//Cannot convert expression of type [][]float64 to type Float64 

Please consider to rename all of your modules from pipelined.dev to github.com/pipelined/:

go get: github.com/pipelined/[email protected]: parsing go.mod:
        module declares its path as: pipelined.dev/vst2
                but was required as: github.com/pipelined/vst2

Iam new to vst programming, so a few questions arise.
It would be awesome if you can give me a hint to the right direction :

  1. I need to set initial patches for some plugins - i guess that could be done via the callback and the opcodes?
  2. How to get all possible opcodes and perhaps possible values for any plugin? (i guess there is a api, wich returns these, because a daw stores and restores patch values as well)

Introduce all VST2 types

To fully support VST2 api, all types from SDK should be present in the package.

This types could be moved to go as they don't contain pointers.

  • VstAEffectFlags -> vst2.EffectFlags
  • AEffectOpcodes -> vst2.EffectOpcodes
  • AEffectXOpcodes -> vst2.EffectOpcodes
  • AudioMasterOpcodes -> vst2.HostOpcodes
  • AudioMasterOpcodesX -> vst2.HostOpcodes
  • VstStringConstants -> vst2 constants
  • Vst2StringConstants -> vst2 constants
  • VstTimeInfo -> vst2.TimeInfo
  • VstTimeInfoFlags -> vst2.TimeInfoFlags
  • VstSmpteFrameRate -> vst2.SMPTEFrameRate
  • VstSpeakerProperties -> vst2.Speaker
  • VstSpeakerArrangement -> vst2.SpeakerArranegement
  • VstSpeakerType -> vst2.SpeakerType
  • VstSpeakerArrangementType -> vst2.SpeakerArrangementType
  • VstEvent
  • VstMidiSysexEvent -> vst2.SysExMIDIEvent
  • ERect -> vst2.EditorRectangle
  • VstMidiEvent -> vst2.MIDIEvent
  • VstEventTypes -> vst2.EventTypes
  • VstMidiEventFlags -> vst2.MIDIEventFlag
  • VstHostLanguage -> vst2.HostLanguage
  • VstProcessPrecision -> vst2.ProcessPrecision
  • VstParameterProperties -> vst2.ParameterProperties
  • VstParameterFlags -> vst2.ParamterFlag
  • VstPinProperties -> vst2.PinProperties
  • VstPinPropertiesFlags -> vst2.PinPropertiesFlags
  • VstPlugCategory -> vst2.PluginCategory
  • MidiProgramName -> vst2.MIDIProgram
  • VstMidiProgramNameFlags -> vst2.MIDIProgramFlag
  • MidiProgramCategory -> vst2.MIDIProgramCategory
  • MidiKeyName -> vsg2.MIDIKey
  • VstUserSpeakerType
  • VstOfflineTaskFlags
  • VstOfflineOption
  • VstAudioFileFlags
  • VstAudioFileMarker
  • VstKeyCode -> vst2.KeyCode
  • VstVirtualKey -> vst2.VirtualKey
  • VstModifierKey -> vst2.ModifierKeyFlag
  • VstFileType
  • VstFileSelectCommand
  • VstFileSelectType
  • VstPatchChunkInfo -> vst2.PatchChunk
  • VstPanLawType -> vst2.PanningLaw
  • VstProcessLevels -> vst2.ProcessLevel
  • VstAutomationStates -> vst2.AutomationState

This types might stay in C as they have pointers inside.

  • VstEvents -> Events
  • VstVariableIo
  • VstOfflineTask
  • VstAudioFile
  • VstFileSelect

lsp attribute reading

When working with a language server for go I encounter the following errors

error   PluginAllocator not declared by package vst2
error   Dispatcher not declared by package vst2
error   unknown field UniqueID in struct (vst2.Plugin) literal
error   unknown field Version in struct (vst2.Plugin) literal
error   unknown field InputChannels in struct (vst2.Plugin) literal
error   unknown field OutputChannels in struct (vst2.Plugin) literal
error   unknown field Name in struct (vst2.Plugin) literal
error   unknown field Vendor in struct (vst2.Plugin) literal
error   unknown field Category in struct (vst2.Plugin) literal
error   unknown field Parameters in struct (vst2.Plugin) literal
error   unknown field ProcessDoubleFunc in struct (vst2.Plugin) literal
error   unknown field ProcessFloatFunc in struct (vst2.Plugin) literal

Can anything be changed in the implementation to address these issues or is this sworn to be another issue of "cgo is not go"?
If the former, I don't know C or CGo, but I'd be happy to learn if you've got any good places to start on the issue
Cheers.

How to build a vst2 synth?

I'd like to use this library to build a synth instead of an effect plugin, but just changing the category was not enough. The synth would need to receive MIDI messages and produce sound in response. Is it currently possible?

Demo plugin not running. Is it out of date?

Hello, I'm on go version go1.16.2 windows/amd64 trying to run the demoplugin/demo.go file but keep getting the following error

# command-line-arguments
.\demo.go:14:2: undefined: vst2.PluginAllocator
.\demo.go:14:57: undefined: vst2.Dispatcher
.\demo.go:21:4: unknown field 'InputChannels' in struct literal of type vst2.Plugin
.\demo.go:22:4: unknown field 'OutputChannels' in struct literal of type vst2.Plugin
.\demo.go:23:4: unknown field 'Parameters' in struct literal of type vst2.Plugin
.\demo.go:26:4: unknown field 'ProcessDoubleFunc' in struct literal of type vst2.Plugin
.\demo.go:36:4: unknown field 'ProcessFloatFunc' in struct literal of type vst2.Plugin
.\demo.go:46:6: undefined: vst2.Dispatcher

Add plugin clean up hook and dispatch handler

Currently plugin doesn't implement any clean-up. What needs to be freed:

  • Plugin double and float buffers (allocated by library);
  • Plugin structure placed into map (done by library);
  • Plugin internal resources (allocated by plugin code) - important note is that plugin developed in Go and go has GC, so most users won't have any recourses to free;

Because resources allocated by both a user and a library must be freed, it's not enough to just provide a hook for the user.

Use logarithmic gain scale in demo plugin

Currently demoplugin uses linear scale for gain. It should use a logarithmic scale with proper to-decibel conversion for display label.

Sample code from thread on JUCE forum:

float LinearToDecibel(float linear)
{
   float db;

   if (linear != 0.0f)
     db = 20.0f * log10(linear);
   else
     db = -144.0f;  // effectively minus infinity

   return db;
}

Host opcodes wrapper functions

  • HostAutomate
  • HostVersion
  • HostCurrentID
  • HostIdle
  • hostPinConnected
  • hostWantMidi
  • HostGetTime
  • HostProcessEvents
  • hostSetTime
  • hostTempoAt
  • hostGetNumAutomatableParameters
  • hostGetParameterQuantization
  • HostIOChanged
  • hostNeedIdle
  • HostSizeWindow
  • HostGetSampleRate
  • HostGetBlockSize
  • HostGetInputLatency
  • HostGetOutputLatency
  • hostGetPreviousPlug
  • hostGetNextPlug
  • hostWillReplaceOrAccumulate
  • HostGetCurrentProcessLevel
  • HostGetAutomationState
  • HostOfflineStart
  • HostOfflineRead
  • HostOfflineWrite
  • HostOfflineGetCurrentPass
  • HostOfflineGetCurrentMetaPass
  • hostSetOutputSampleRate
  • hostGetOutputSpeakerArrangement
  • HostGetVendorString
  • HostGetProductString
  • HostGetVendorVersion
  • HostVendorSpecific
  • hostSetIcon
  • HostCanDo
  • HostGetLanguage
  • hostOpenWindow
  • hostCloseWindow
  • HostGetDirectory
  • HostUpdateDisplay
  • HostBeginEdit
  • HostEndEdit
  • HostOpenFileSelector
  • HostCloseFileSelector
  • hostEditFile
  • hostGetChunkFile
  • hostGetInputSpeakerArrangement

Plugin opcodes wrapper functions

Dispatch and host callback functions have vague semantics that treat parameters depending on what opcode is provided. It's not user-friendly and error prone. The more convenient approach would be to provide wrapper functions where user can always provide exact parameters and avoid error-prone and unsafe castings.

Strikethrough opcodes are deprecated

Opcodes:

  • EffOpen (vst2.VST::Load)
  • EffClose (vst2.Plugin::Close)
  • EffSetProgram (vst2.Plugin::SetProgram)
  • EffGetProgram (vst2.Plugin::Program)
  • EffSetProgramName (vst2.Plugin::SetProgramName)
  • EffGetProgramName (vst2.Plugin::CurrentProgramName)
  • EffGetParamLabel (vst2.Plugin::ParamUnitName)
  • EffGetParamDisplay (vst2.Plugin::ParamValueName)
  • EffGetParamName (vst2.Plugin::ParamName)
  • effGetVu
  • EffSetSampleRate (vst2.Plugin::SetSampleRate)
  • EffSetBufferSize (vst2.Plugin::SetBufferSize)
  • EffStateChanged (vst2.Plugin::Start; vst2.Plugin::Stop)
  • EffEditGetRect
  • EffEditOpen
  • EffEditClose
  • effEditDraw
  • effEditMouse
  • effEditKey
  • EffEditIdle
  • effEditTop
  • effEditSleep
  • effIdentify
  • EffGetChunk
  • EffSetChunk
  • EffProcessEvents
  • EffCanBeAutomated
  • EffString2Parameter
  • effGetNumProgramCategories
  • EffGetProgramNameIndexed (vst2.Plugin::ProgramName)
  • effCopyProgram
  • effConnectInput
  • effConnectOutput
  • EffGetInputProperties
  • EffGetOutputProperties
  • EffGetPlugCategory
  • effGetCurrentPosition
  • effGetDestinationBuffer
  • EffOfflineNotify
  • EffOfflinePrepare
  • EffOfflineRun
  • EffProcessVarIo
  • EffSetSpeakerArrangement (vst2.Plugin::SetSpeakerArrangement)
  • effSetBlockSizeAndSampleRate
  • EffSetBypass
  • EffGetEffectName
  • effGetErrorText
  • EffGetVendorString
  • EffGetProductString
  • EffGetVendorVersion
  • EffVendorSpecific
  • EffCanDo
  • EffGetTailSize
  • effIdle
  • effGetIcon
  • effSetViewPosition
  • EffGetParameterProperties (vst2.Plugin::ParamProperties)
  • effKeysRequired
  • EffGetVstVersion
  • EffEditKeyDown
  • EffEditKeyUp
  • EffSetEditKnobMode
  • EffGetMidiProgramName
  • EffGetCurrentMidiProgram
  • EffGetMidiProgramCategory
  • EffHasMidiProgramsChanged
  • EffGetMidiKeyName
  • EffBeginSetProgram
  • EffEndSetProgram
  • EffGetSpeakerArrangement
  • EffShellGetNextPlugin
  • EffStartProcess
  • EffStopProcess
  • EffSetTotalSampleToProcess
  • EffSetPanLaw
  • EffBeginLoadBank
  • EffBeginLoadProgram
  • EffSetProcessPrecision
  • EffGetNumMidiInputChannels
  • EffGetNumMidiOutputChannels

Plugin dispatch API

Provide dispatch API, so plugin developers won't have to deal with unsafe casting in dispatch calls.

Build plugins on OS X as Mach-O bundle

go build --buildmode c-shared produces Mach-O dynamically linked shared library x86_64. This is different from what other plugins do.

Some DAWs would still recognise (tested with Renoise) plugin if this dylib is placed in the bundle. However, Ableton doesn't detect such plugin.

Building plugins

In theory this package should allow people building VST2 plugins in go. This issue will track the progress in this effort.

Compilation and build:

  • Create package to enable export of plugin functions;
  • Build a shared-lib with c-shared build mode;

Build command (OS X):

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.