public virtual bool open( int block_size, int sample_rate )
{
dllHandle = win32.LoadLibraryExW( path, IntPtr.Zero, win32.LOAD_WITH_ALTERED_SEARCH_PATH );
if ( dllHandle == IntPtr.Zero ) {
serr.println( "vstidrv#open; dllHandle is null" );
return false;
}
mainProcPointer = win32.GetProcAddress( dllHandle, "main" );
mainDelegate = (PVSTMAIN)Marshal.GetDelegateForFunctionPointer( mainProcPointer,
typeof( PVSTMAIN ) );
if ( mainDelegate == null ) {
serr.println( "vstidrv#open; mainDelegate is null" );
return false;
}
audioMaster = new audioMasterCallback( AudioMaster );
if ( audioMaster == null ) {
serr.println( "vstidrv#open; audioMaster is null" );
return false;
}
aEffectPointer = IntPtr.Zero;
try {
aEffectPointer = mainDelegate( audioMaster );
} catch ( Exception ex ) {
serr.println( "vstidrv#open; ex=" + ex );
return false;
}
if ( aEffectPointer == IntPtr.Zero ) {
serr.println( "vstidrv#open; aEffectPointer is null" );
return false;
}
blockSize = block_size;
sampleRate = sample_rate;
aEffect = new AEffectWrapper();
aEffect.aeffect = (AEffect)Marshal.PtrToStructure( aEffectPointer, typeof( AEffect ) );
aEffect.Dispatch( AEffectOpcodes.effOpen, 0, 0, IntPtr.Zero, 0 );
int ret = aEffect.Dispatch( AEffectOpcodes.effSetSampleRate, 0, 0, IntPtr.Zero, (float)sampleRate );
#if DEBUG
sout.println( "vstidrv#open; dll_path=" + path + "; ret for effSetSampleRate=" + ret );
#endif
aEffect.Dispatch( AEffectOpcodes.effSetBlockSize, 0, blockSize, IntPtr.Zero, 0 );
// デフォルトのパラメータ値を取得
int num = aEffect.aeffect.numParams;
paramDefaults = new float[num];
for ( int i = 0; i < num; i++ ) {
paramDefaults[i] = aEffect.GetParameter( i );
}
return true;
}