VSTi : note stucked

Started by Franck REVOLLE,

Franck REVOLLE

Hereafter, a very basic test in C++, using VSTi on a mixer.
A note is stucked (or stucks other, or is OK, depending the position (cf. remarks...). Silence should exist when "Silence" is printed.
The issue is the same, with four different VSTi, ant the two VSTi methods.
The issue does not appear with other VSTi Host (e.g. MiniHost http://www.brothersoft.com/minihost-download-168293.html)
The Vsti tested are free on the Net (http links inside the C sample)
Thank you in advance for your support.

// VSTi BASS test, with one note stucked
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <mmsystem.h>
#include "bass.h"
#include "bassmidi.h"
#include "bass_vst.h"
#include "bassmix.h"

// the VSTi DLL with the same issue
///////////////////////////////////
//#define VST_DLL "Accordion.dll" // http://www.dontcrack.com/freeware/downloads.php/id/3598/software/Accordion/
#define VST_DLL "Peti_Demo.dll" // http://nusofting.liqihsynth.com/peti.html
//#define VST_DLL "Organux demo.dll" // http://www.brothersoft.com/downloads/organux-vst.html
//#define VST_DLL "mellowsound.dll" // http://www.pcmusic.org/software/releases.php/lang/en/id/3404/view/VST

DWORD chMixer ; // BASS mixer handle
DWORD chVsti ; // VSTi channel connected on the mixer handle
#define dSleep 2000 // ms between each group of messages to the VSTi

void msgVST(bool on , BYTE pitch )
{
   int ret ;
   DWORD m0, m1, m ;
   if (on == true)
   {
      m0 = 0x90 ;
      m0 <<= 16 ;
      m1 = (DWORD)(pitch) ;
      m1 <<= 8 ;
      m = m0 + m1 + 0x64 ;
      // same issue with the two methods :
      //ret = BASS_VST_ProcessEventRaw(chVsti,(void*)(m), 0) ;
      ret = BASS_VST_ProcessEvent(chVsti, 0, MIDI_EVENT_NOTE, MAKEWORD(pitch, 100));
   }
   else
   {
      m0 = 0x80 ;
      m0 <<= 16 ;
      m1 = (DWORD)(pitch) ;
      m1 <<= 8;
      m = m0 + m1 ;
      // same issue with the two methods :
      //ret = BASS_VST_ProcessEventRaw(chVsti,(void*)(m), 0) ;
      ret = BASS_VST_ProcessEvent(chVsti, 0, MIDI_EVENT_NOTE, MAKEWORD(pitch, 0));
   }
   printf("%d %d %x\n",on, pitch,m);
   if (! ret)
      printf("error process event %d\n", BASS_ErrorGetCode());
}
void silence(){   printf("silence\n");Sleep(dSleep);}
void tenuto(){   printf("tenuto\n");   Sleep(dSleep);}
int _tmain(int argc, _TCHAR* argv[])
{
   // Open Bass
   BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD,10);
   if (!BASS_Init(-1,44100,BASS_DEVICE_LATENCY | BASS_DEVICE_NOSPEAKER , 0,NULL))
   {
      printf("Error Bass_init %d", BASS_ErrorGetCode());
      return -1;
   }
   BASS_INFO info ;
   BASS_GetInfo(&info);
   BASS_SetConfig(BASS_CONFIG_BUFFER,30+info.minbuf);
   // Open mixer
   chMixer = BASS_Mixer_StreamCreate( 44100, 2, 0) ;
   if (chMixer == 0)
   {
      printf("Error Mixer_StreamCreate %d\n",BASS_ErrorGetCode());
      BASS_Free();
      return -1;
   }
   if (BASS_ChannelPlay(chMixer,FALSE) == 0)
   {
      printf("Error ChannelPlay %d\n",BASS_ErrorGetCode());
      BASS_Free();
      return -1;
   }
   // Open VSTi
   chVsti = BASS_VST_ChannelCreate(44100, 2, VST_DLL , BASS_STREAM_DECODE );
   if (chVsti == 0)
   {
      printf("error open dll %d\n", BASS_ErrorGetCode());
      BASS_Free();
      return -1;
   }
   if ( BASS_Mixer_StreamAddChannel( chMixer, chVsti , BASS_STREAM_AUTOFREE) == 0)
   {
      printf("Errot Mixer AddChannel %d)",BASS_ErrorGetCode());
      BASS_VST_ChannelFree(chVsti);
      BASS_Free();
      return -1;
   }
   // play on VSTi
   silence();
      msgVST(true ,0x45 ) ;   
      msgVST(true ,0x41 ) ;   
         Sleep(dSleep);   
      msgVST(false,0x45 ) ;   
      msgVST(false ,0x41 ) ;   
   silence();
      msgVST(true ,0x45 ) ;   
      msgVST(true ,0x41 ) ;   
      msgVST(true ,0x55 ) ;   // note-on 55
         Sleep(dSleep);
      msgVST(false ,0x45 ) ;   
      msgVST(false ,0x41 ) ;   
   // msgVST(false ,0x55 ) ; // if note-off 55 here, OK   
   tenuto();
      msgVST(true ,0x46 ) ;   
      msgVST(true ,0x42 ) ;   
         Sleep(dSleep);   
      msgVST(false ,0x55 ) ; // if note-off 55 here, stucked !!   
      msgVST(false ,0x46 ) ;   
      msgVST(false ,0x42 ) ;   
      // msgVST(false ,0x55 ) ; //if note-off 55 here, stucks the two notes before  !!   
   silence();
      msgVST(true ,0x45 ) ;   
      msgVST(true ,0x41 ) ;   
         Sleep(dSleep);   
      msgVST(false ,0x45 ) ;   
      msgVST(false ,0x41 ) ;   
   silence();
   Sleep(5000);
   // close
   BASS_VST_ChannelFree(chVsti);
   BASS_StreamFree(chMixer);
   BASS_Free();

   return 0 ;
}

bpetersen

Hello,

I've fixed and rewritten some processing, things should work much better now.

Please try the new version from http://www.un4seen.com/forum/?topic=5559.0 and please let me know if there are any further problems regarding this point.

Best regards,
Bjoern Petersen

Franck REVOLLE

 :) It seems OK.
The notes are not more stucked with the test program
Thank you for your support.

bpetersen

No problem, you're welcome.

Regards,
Bjoern