' **************************************************** ' * Music Composition Software * ' * by * ' * Em.Prof.Dr.Godfried-Willem Raes * ' * * ' * This source code compiles to * ' * Compile with PBWIN V10.04 * ' * Version 10.09 * ' **************************************************** '22/06/2006 g_wave split off into a separate dll g_wave.dll '2008.08.12 further debugging. both modes are working now in the Rational melodies (Tom Johnson) code.. ' next test is picrada.. ' TO DO: decent clean up on Gmt exit.. '31.08.2008: adapted to compiler PB9 - events var.name changed '07.06.2009: attempting to compile and run with NiDAQmx - ok. '08.07.2009: check through by gwr. '11.07.2009: some logfile instruction remmed out in stoptask/starttask '30.03.2011: Upgrade to PBWin10 '20.03.2012: recompiled after removal of some logfile instructions in QSchedulevent. '09.04.2012: recompile with some fields in Task and App changed to single. '30.05.2012: resource files modified. Legacy hardware removed. '08.02.2013: resource files updated. '03.04.2013: Update PB Win 10.04 '06.06.2014: Recompiled. '03.04.2016: Chi added. Resource must contain all robot icons! '13.09.2016: HybrLo added. '04.02.2017: Bug and Melauton added. '12.04.2019: Balsi added, this lib included in code for Hex-2019 '13.04.2019: This library can also be included in PBCC programs. '20.09.2019: Tubo added '17.01.2020: Flut added '02.05.2021: Roro added '02.01.2022: Steely added '02.03.2022: 3PI added '%NetworkSupport = 1 ' metacompiler constant. Include for netsupport in this dll. '%include_wavefunctions=1 ' metacompiler constant - everything marked with this is dependent from g_Wave, which we isolated from this dll ' we should try to move everything marked like this to g_wave '%include_mixerfunctions=1 '%use_queuetimers_allways = 1 'meta compile constant. if this is defined, timerqueue timers are used for tasks in stead of the timesetevent. 'on Winxp they are less accurate, on vista they are accurate up to 1 ms, same on windows 7 ' this allows you to have up to 1000's of timers in stead of a dozen, and they stay in sync.. ' ' 2008.08.05 seems to work.. now try if the gestrobo and picra code work better this way.. ' 2009.05.xx qeueud timer task with high frequency seem to interfere with gui responsiveness up to crashing level.. ' tasks with TaskEx.startcptr's cause crashes with qeueud timers - it seems that the opt byval param of certain functions gives problems? '%choose_timer_mode = 1 'TO BE TESTED let the user decide on the kind of timer.. fast task and tasks where precise ' timing is critical best use the timesetevent on winxp.. ' in this modus, tasks with the %QUEUE_TASK flag work with TimerQueue timers, the other ones with timesetevent ' obviously, the 2 above timer modes should never be combined.. ' %timerdbg = 1 'enable logs in timer functions #COMPILER PBWIN 10 ', PBWIN 9 #COMPILE DLL "g_lib.dll" #RESOURCE "resource\g_lib.pbr" ' resource contains cockpit, strings, the about boxes and icons. '#resource "resource\g_lib.res" ' does not work!!! #OPTION VERSION5 ' 5=compile for Windows2000 and/or NT5 #REGISTER ALL ' This metastatement should appear only once. #DIM ALL #TOOLS OFF #DEBUG ERROR OFF ' this slows down the code and should be only set during development!!! #INCLUDE ONCE "..\winapi\g_win.inc" ' only the types, declares and constants used by GMT #INCLUDE ONCE "g_kons.bi" ' integer constants and strings #INCLUDE ONCE "g_type.bi" ' This declares all our own structures, user defined types #INCLUDE ONCE "g_indep.bi" ' independent function library. (dll) #INCLUDE ONCE "g_file.bi" ' file I/O library #INCLUDE ONCE "g_har.bi" ' harmony library #INCLUDE ONCE "g_mus.bi" ' music composition library %UDP = 1 ' if defined we compile with UDP/MIDI support. [25.12.2006] #IF %DEF(%UDP) #INCLUDE ONCE "g_net.bi" ' include network I/O support - for UDP listen procedures #ENDIF %g_lib_inc = %True #INCLUDE ONCE "g_lib.bi" ' exported procs. and functions #INCLUDE ONCE "g_mm.bi" ' required again! definition of vaccanotes.. #INCLUDE ONCE "g_wave.bi" #INCLUDE ONCE "g_wmix.bi" ' doubled from gmt_main: GLOBAL La AS SINGLE ' value read in ini-file GLOBAL GrondDo AS SINGLE ' calculated on initialisation in procedure initglobalvariables GLOBAL Domq AS SINGLE ' idem. GLOBAL hInstDLL AS DWORD ' 04.04.2000 ' MIDI related variables: ' following 2 arrays dimmed at adres of these in gmt.bas GLOBAL hMidiO() AS DWORD ' doubled with GMT - orig in dll, dimmed @pointer in GMT 22.07.2004 GLOBAL hMidiI() AS DWORD ' doubled with GMT GLOBAL SxB() AS STRING * %SysExBuffer 'this contains all received SysEx msg's. GLOBAL MiBuf() AS STRING * %MidiBuffer 'one buffer for each midi port GLOBAL ListenMask AS QUAD ' new 20.12.2002 - the bits set the channels to receive midi from. ' port 0 channels are in bits 0-15, port 1 in 16-31, port 2 32-47, port 3 ' in bits 48-63 ' For further expansion, we will need a special type. ' new 10.01.2004 GLOBAL ListenMask2 AS QUAD ' if the varptr of this one = varptr(listenmask + 8), we can safely ' use bit positions up to 127 . Checked in init g_lib GLOBAL Listenmask3 AS QUAD ' now we can support 16 midi -input ports and use the bit mask! GLOBAL Listenmask4 AS QUAD ' end new GLOBAL SxB0 AS STRING * %SysExBuffer ' primary sysex receive buffer filled by device driver GLOBAL SxB1 AS STRING * %SysExBuffer ' secondary sysex receive buffer filled in the callback. GLOBAL SxThread AS GMT_SYSEX_THREAD ' made global 23.10.1999 , passed to DLL byref. GLOBAL MidiSXHdr0 AS MIDIHDR ' for receiving sysex dumps. [22.10.99] GLOBAL Seq AS SequencerType ' for playseq task 16.07.01 ' midi delaybuffers: GLOBAL DelayNoteArray() AS WORD ' this cannot be a type, because the arrays have to be dynamic GLOBAL DelayTimeArray() AS DWORD ' timing with millisecond resolution ' midi based radar sensing devices: [PICradar] GLOBAL PicRad() AS RadarPicController '21.07.2004 ' data buffers for these devices: [ maximum 8 devices!!!] GLOBAL a0buf() AS INTEGER ' global since 23.07.2004 GLOBAL t0buf() AS INTEGER ' dimmed in GetPicRadarpointer in g_midi.inc GLOBAL a1buf() AS INTEGER GLOBAL t1buf() AS INTEGER GLOBAL a2buf() AS INTEGER GLOBAL t2buf() AS INTEGER GLOBAL a3buf() AS INTEGER GLOBAL t3buf() AS INTEGER GLOBAL a4buf() AS INTEGER GLOBAL t4buf() AS INTEGER GLOBAL a5buf() AS INTEGER GLOBAL t5buf() AS INTEGER GLOBAL a6buf() AS INTEGER GLOBAL t6buf() AS INTEGER GLOBAL a7buf() AS INTEGER GLOBAL t7buf() AS INTEGER ' data buffers for the Hybridsensor HY1 device - gwr 07.10.2007 GLOBAL hy0buf() AS INTEGER ' dimmed in GetHY1SensorPointer in g_midi.inc GLOBAL hy1buf() AS INTEGER ' contains 10 bit data arrays GLOBAL hy2buf() AS INTEGER GLOBAL hy3buf() AS INTEGER GLOBAL hy4buf() AS INTEGER ' data buffers for AXE1 acceleration sensor device - gwr 22.10.2007 GLOBAL ax0buf() AS INTEGER ' dimmed in GetAX3SensorPointer in g_midi.inc GLOBAL ax1buf() AS INTEGER ' contains 10 bit data arrays GLOBAL ax2buf() AS INTEGER GLOBAL ax3buf() AS INTEGER ' data buffers for PIR2 sensor device - gwr 17.11. 2007 GLOBAL pirlbuf() AS INTEGER ' dimmed in GetPIR2Sensorpointer in g_midi.inc GLOBAL pircbuf() AS INTEGER GLOBAL pirrbuf() AS INTEGER ' data buffers for HANDY sensor device - gwr 30.12.2007 GLOBAL h0buf() AS INTEGER ' dimmed in GetHandySensorPointer in g_midi.inc GLOBAL h1buf() AS INTEGER GLOBAL h2buf() AS INTEGER GLOBAL h3buf() AS INTEGER GLOBAL h4buf() AS INTEGER GLOBAL h5buf() AS INTEGER GLOBAL h6buf() AS INTEGER GLOBAL h7buf() AS INTEGER #IF %DEF(%include_wavefunctions) ' AUDIO related variables: GLOBAL hWO() AS DWORD ' 04.03.2000 - copy in GMT in Audio.hWo GLOBAL hWI() AS DWORD ' 04.03.2000 - copy in GMT in Audio.hWi GLOBAL AudioFormat AS WAVEFORMATEX ' 04.03.2000 GLOBAL Spec() AS SINGLE #ENDIF GLOBAL MM() AS musician PTR ' 16.01.2005 - orig. in g_mm.inc - used in Publish_MM () GLOBAL MMTrack() AS musician ' for MM Midiplayer.. new 20051007 GLOBAL Si AS ScrollInfo ' for MM MidiPlayer 20101222 GLOBAL Hybridsensor AS Hybridsensor_HY1 '05.10.2007 GLOBAL Ax3sensor AS Axe_Type '22.10.2007 GLOBAL Pir2Sensor AS PIR_Type '17.11.2007 GLOBAL Handy AS Handysensor '30.12.2007 #IF %DEF(%include_wavefunctions) ' following globals are the real time audio buffers: ' we use wave buffers as audiotracks... - allocation is dynamic. ' In order to guarantee the pointers to start on 32-bit boundaries, ' we declared these as DWORD. ' one dword contains a single stereo sample coded as: ' left-channel sample = HIWORD(AudioTrack(i)) ' right-channel sample = LOWORD(AudioTrack(i)) GLOBAL AudioTrack0() AS DWORD GLOBAL AudioTrack1() AS DWORD GLOBAL AudioTrack2() AS DWORD GLOBAL AudioTrack3() AS DWORD GLOBAL AudioTrack4() AS DWORD GLOBAL AudioTrack5() AS DWORD GLOBAL AudioTrack6() AS DWORD GLOBAL AudioTrack7() AS DWORD GLOBAL AudioTrack8() AS DWORD GLOBAL AudioTrack9() AS DWORD GLOBAL AudioTrackA() AS DWORD GLOBAL AudioTrackB() AS DWORD GLOBAL AudioTrackC() AS DWORD GLOBAL AudioTrackD() AS DWORD GLOBAL AudioTrackE() AS DWORD GLOBAL AudioTrackF() AS DWORD '---------- for audio output: GLOBAL Stream AS STREAMMIXBUFFER ' cfr. gmt_types - 28.03.2000 ' this contains static arrays used for streaming mixer GLOBAL StreamMix AS STREAMCHANNELS ' cfr. gmt_types - new 28.03.2000 ' the pointers to these data arrays should now be ' fixed at compile time. GLOBAL StreamHdr AS STREAMHEADERS ' contains the WaveHeader structures. '----------- for audio input: GLOBAL StrInHdr AS STREAMHEADERS ' contains waveheader structures for recording GLOBAL StreamIn AS STREAMINBUFFER ' contains the static data arrays for recording GLOBAL RecTrack() AS DWORD ' recording buffer '------------------------ GLOBAL Audio AS AUDIOTYPE ' 24.08.1999 in GMT, introduced in DLL 05.03.2000 GLOBAL pTrackStat AS AudioTrackStatus PTR ' 0-15 are normal tracks, 17,18 are the mixertracks ' 19,20 are the input buffers ' 05.03.2000 - value initialized in callbacks for waveIN/OUT GLOBAL pWbh() AS WAVEHDR PTR ' array of pointers to the the wavebufferheaders declared and dimensioned in GMT GLOBAL mWbh() AS WAVEHDR ' wavebufferheaders for the mixer used in streaming audio (mixertracks) GLOBAL RecWbh AS WAVEHDR ' wavebufferheader for the recording in streaming mode. #ENDIF ' GLOBAL CritSec AS Critical_Section ' used in the wavecallbacks - removed 22.12.2002 ' GLOBAL CritSecTask AS Critical_Section ' used in the timercallback for the tasks ' pointers to the world created in the GMT application: (set in Init_lib_pointers) GLOBAL pTask() AS Taak PTR ' pointers to the global Task() structures in GMT. GLOBAL pTaskEX() AS ExtraInfo PTR ' pointers to TaskEX() structures GLOBAL pApp AS ApplicationType PTR ' pointer to App structure in GMT GLOBAL pMCIid AS MCIdeviceType PTR ' 09.04.2000 GLOBAL pAudioCD AS AudioCDtype PTR ' 09.04.2000 GLOBAL pgh AS GMT_HANDLES PTR ' 21.04.2000 - handles to gmt windows created in GMT GLOBAL pMeq() AS MidiEquipment PTR ' 22.04.2000 - ok - removed 12.06.2002 GLOBAL pUDCtrl() AS UpDownController PTR ' 24.04.2000 - ok GLOBAL pButnSW() AS SwitchController PTR ' 24.04.2000 GLOBAL pButnOS() AS OneShotController PTR ' 24.04.2000 GLOBAL pSlider() AS SliderController PTR ' 24.04.2000 - ok GLOBAL pStaff AS StaffType PTR ' 03.05.2000 - ok GLOBAL pFunctionKey() AS FunctionKeyController PTR '04.05.2000 GLOBAL pKeyboard AS KeyboardController PTR '04.05.2000 ' for x-tof's timer research: (must be here, not in g_hgen... GLOBAL tid() AS DWORD 'if we stick to the queued timers, we'd better make this a field in the task type GLOBAL htq AS DWORD ' what's this for ??? #IF %DEF(%include_mixerfunctions) GLOBAL pAudioFader() AS AudioFaderType PTR '11.05.2000 GLOBAL pWaveFader() AS AudioFaderType PTR '11.05.2000 GLOBAL pOutPutMixer AS AudioMixerLineType PTR '13.05.2000 GLOBAL pInputMixer AS AudioMixerLineType PTR '13.05.2000 #ENDIF ' ------------------------------------------------------ ' quart sine-wave lookup: ' 19.04.2000 GLOBAL WaveLets AS WaveLetData ' filled and calculated in g_mus.dll - 20.12.2001 GLOBAL kompilfile AS STRING ' new 24.06.2002 : contains the name of the executable loading this lib. GLOBAL TiEv() AS TimedEvent ' 09.10.2003 'declares for not-exported procedures and functions: DECLARE FUNCTION Init_g_lib () AS DWORD DECLARE FUNCTION g_taskProc (BYVAL wTimerID AS LONG, BYVAL msg AS LONG, BYVAL TaskNr AS LONG, BYVAL dw1 AS LONG, BYVAL dw2 AS LONG) AS LONG DECLARE FUNCTION g_PerTaskProc (BYVAL wTimerID AS LONG, BYVAL msg AS LONG, BYVAL TaskNr AS LONG, BYVAL dw1 AS LONG, BYVAL dw2 AS LONG) AS LONG DECLARE FUNCTION AboutProc (BYVAL h AS LONG, BYVAL w AS LONG, BYVAL wP AS LONG, BYVAL lP AS LONG) AS LONG DECLARE FUNCTION Update_MidiEquipment (BYREF Meq() AS MidiEquipment) AS DWORD DECLARE FUNCTION RMouseMessageHandler (msg AS tagMSG) AS LONG DECLARE FUNCTION MonitorHandler (BYVAL hW AS LONG, BYVAL wM AS LONG, BYVAL wP AS LONG, BYVAL lP AS LONG)AS LONG ' gmt jitter monitoring: ' new 10.10.2003 DECLARE FUNCTION MTSpeed (BYVAL onoff AS DWORD) AS DWORD DECLARE FUNCTION MTSpeed_TCB (BYVAL wTimerID AS LONG, BYVAL msg AS LONG, BYVAL Tstart AS LONG, BYVAL dw1 AS LONG, BYVAL dw2 AS LONG) AS DWORD 'declare function RunTime (byval onoff as dword) as dword DECLARE FUNCTION RunTime_TCB (BYVAL wTimerID AS LONG, BYVAL msg AS LONG, BYVAL Tstart AS LONG, BYVAL dw1 AS LONG, BYVAL dw2 AS LONG) AS DWORD DECLARE FUNCTION ShowPromil_TCB (BYVAL wTimerID AS LONG, BYVAL msg AS LONG, BYVAL Tstart AS LONG, BYVAL dw1 AS LONG, BYVAL dw2 AS LONG) AS DWORD 'DECLARE SUB DelnonGwrItems (BYVAL hmenu AS DWORD) removed 08.03.2005 #IF %DEF(%include_wavefunctions) DECLARE SUB ReportWaveInError (BYVAL ID AS LONG, BYVAL device AS LONG) DECLARE SUB ReportWaveOutError (BYVAL ID AS LONG, BYVAL device AS LONG) DECLARE FUNCTION GetFreeAudioBuffer () AS LONG DECLARE FUNCTION MatchAudioTrackWithBuffer (BYVAL tracknr AS LONG) AS LONG DECLARE FUNCTION PlayAudioMix (BYVAL param AS LONG) AS LONG ' thread function used for streamaudio playing DECLARE SUB MixChunk (BYVAL buftog AS LONG) DECLARE SUB ReportError (BYVAL ID AS INTEGER) DECLARE FUNCTION ProcWaveOutCallBack (BYVAL hWo AS DWORD, BYVAL wMsg AS LONG, BYVAL dwInstance AS DWORD,_ BYVAL wParam AS LONG, BYVAL lParam AS LONG)AS LONG DECLARE FUNCTION ProcWaveInCallBack (BYVAL hWi AS DWORD, BYVAL wMsg AS LONG, BYVAL dwInstance AS DWORD,_ BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG DECLARE CALLBACK FUNCTION ProcHdlgWavOut ' gwr - should be here! DECLARE CALLBACK FUNCTION ProcHdlgWavin ' gwr #ENDIF ' #IF %DEF(%include_mixerfunctions) DECLARE FUNCTION MixAppGetControlTypeName (pmxctrl AS MIXERCONTROL) AS STRING ' C-code #ENDIF ' callback declaration for our FromTo's and timed events: DECLARE FUNCTION FromTo_CB (BYVAL wTimerID AS LONG, BYVAL msg AS LONG, BYVAL p AS LONG, BYVAL dw1 AS LONG, BYVAL dw2 AS LONG) AS DWORD DECLARE FUNCTION ScheduleEvent_CB (BYVAL wTimerID AS LONG, BYVAL msg AS LONG, BYVAL evnt AS LONG, BYVAL dw1 AS LONG, BYVAL dw2 AS LONG) AS DWORD ' listentask and interface for listentask for Picradar devices DECLARE SUB PicRadarInput() 'no longer exported since 23.07.2004 DECLARE SUB PicRadarInput_Stop () DECLARE SUB PicRadar_Slider_dta () DECLARE SUB PicRadar_Slider_dtf () ' not exported in g_main inc: procs. for radar, sonar, sonarranger and CQT parameter control: DECLARE SUB Dummy_Task () DECLARE FUNCTION Quadrada_Noise_Slider0 () AS DWORD DECLARE FUNCTION Quadrada_Noise_Slider1 () AS DWORD DECLARE FUNCTION Quadrada_Noise_Slider2 () AS DWORD DECLARE FUNCTION Quadrada_Noise_Slider3 () AS DWORD DECLARE FUNCTION Quadrada_Sfakt () AS DWORD DECLARE FUNCTION Quadrada_dt () AS DWORD DECLARE FUNCTION Quadrada_dta () AS DWORD DECLARE FUNCTION Quadrada_DisplayMode () AS DWORD DECLARE FUNCTION Sonar_Noise_Slider () AS DWORD DECLARE FUNCTION Sonar_dta () AS DWORD DECLARE FUNCTION Sonar_dtf () AS DWORD DECLARE FUNCTION Sonar_dT () AS DWORD DECLARE SUB CQT_Slider0 () DECLARE SUB CQT_Slider1 () DECLARE SUB CQT_Slider2 () DECLARE SUB CQT_Slider3 () DECLARE SUB CQT_UD_CC40 () DECLARE SUB CQT_UD_1 () DECLARE SUB CQT_UD_2 () DECLARE SUB CQT_UD_3 () DECLARE SUB CQT_UD_4 () DECLARE SUB CQT_UD_5 () DECLARE SUB SonarRanger_Near_Slider () DECLARE SUB SonarRanger_Far_Slider () DECLARE SUB SonarRanger_rate_slider () DECLARE SUB SonarRanger_dT () DECLARE SUB SonarRanger_dv () DECLARE FUNCTION Doppler_Noise_Slider () AS DWORD ' 07.07.2009 gwr DECLARE FUNCTION Doppler_Dta_Slider () AS DWORD DECLARE FUNCTION Doppler_Hpf_Slider () AS DWORD ' 08.07.2009 DECLARE FUNCTION Doppler_Acc_Slider () AS DWORD ' 12.07.2009 'not exported in g_midi.inc (for midi fileplayer) DECLARE FUNCTION Notemap_nrinput (ID AS LONG, hw AS LONG) AS LONG DECLARE CALLBACK FUNCTION procMidiPlayerStartWin DECLARE CALLBACK FUNCTION cbMMNotemap DECLARE CALLBACK FUNCTION CBMMnm_nrinput DECLARE CALLBACK FUNCTION cbMM_mute DECLARE FUNCTION MMChMap (BYVAL md AS parsedmiditype, OPT BYVAL trackinfo$, OPT BYVAL wh AS DWORD) AS WORD DECLARE FUNCTION SoMap (BYVAL md AS ParsedMidiType) AS LONG DECLARE FUNCTION SireMap (BYVAL md AS ParsedMidiType, OPT BYVAL ID AS BYTE) AS LONG DECLARE FUNCTION VaccaMap (BYVAL md AS ParsedMidiType) AS LONG DECLARE FUNCTION LlorMap (BYVAL md AS ParsedMidiType) AS LONG DECLARE FUNCTION Notemap (BYVAL md AS parsedmiditype, OPT BYVAL cpnfilt AS DWORD, OPT BYVAL wh AS DWORD, OPT BYVAL CLEAR AS LONG) AS LONG DECLARE FUNCTION MMNotemap (BYVAL md AS parsedmiditype, OPT BYVAL channel AS DWORD, OPT BYVAL trackinfo$, OPT BYVAL wh AS DWORD, OPT BYVAL msg1 AS DWORD, OPT BYVAL msg2 AS DWORD) AS LONG #INCLUDE ONCE "g_main.inc" ' source code for gmt main module #INCLUDE ONCE "g_hgen.inc" ' general procs. #INCLUDE ONCE "g_math.inc" ' source code for math library '#INCLUDE once "g_wave.inc" #INCLUDE ONCE "g_mci.inc" #INCLUDE ONCE "g_midi.inc" '#INCLUDE once "g_wmix.inc" FUNCTION DLLMAIN(BYVAL hInstance AS LONG, _ BYVAL fwdReason AS LONG, _ BYVAL lpvReserved AS LONG) AS LONG ' here we should initialize data used globally. ' also we should force a read of the data files. ' Note that hInstance is the instance handler of the dll, not of GMT !!! 'changed kl 20051026 hInstDLL = hInstance ' so we know for sure we are dealing with the dll's instance handle. DLLMAIN = %True LOCAL i AS LONG SELECT CASE fwdReason CASE %DLL_PROCESS_ATTACH Init_g_lib 'Dit was fout! hInstance is _niet_ de handle van het huidige proces! [ tot 26.10.2005] ' SetPriorityClass (hInstance, %NORMAL_PRIORITY_CLASS) 'Het volgende werkt wel [sedert 26.10.2005] ' GetCurrentprocess retourneert -1, wat geinterpreteerd wordt als "het huidig proces" ' exe en dll blijken trouwens in hetzelfde proces te zitten! ' (de priority die we hier geven verschijnt voor de exe in de taskmanager) ' er is dan ook niet echt een reden om dit hier te doen (?) i = SetPriorityClass (GetCurrentProcess(), %REALTIME_PRIORITY_CLASS) 'getcurrentprocess returns -1, which is the right value according to the docs 'de priority lijk weinig invloed te hebben op onze midi timing problemen 'het enige verschil dat we gemerkt hebben: op realtime kan je in de pb editor scrollen zonder dat 'dat het gmt midispelen vertraagt, anders niet.. 'nog niet gecheckt met bewegingsinput en zo.. IF ISFALSE(i)THEN warning "failed setting priorityclass!" '-> niet orthodox om hier een warning te gebruikten, maar 't werkt... warning STR$(Getlasterror) END IF CASE %DLL_PROCESS_DETACH, %DLL_THREAD_ATTACH, %DLL_THREAD_DETACH 'niks CASE ELSE DLLMAIN = %False END SELECT END FUNCTION FUNCTION Init_g_lib () AS DWORD ' initialize global variables that are in fact non-integer numeric constants. ' La - now read from *.INI file, so tuning can be external. ' This procedure is called on initialisation of the dll. STATIC init AS DWORD LOCAL dummy! LOCAL Wbh AS WAVEHDR LOCAL l AS DWORD IF ISFALSE init THEN DIM SxB(0) AS GLOBAL STRING * %SysExBuffer DIM MiBuf(MAX(0, midiInGetNumDevs-1)) AS GLOBAL STRING * %MidiBuffer ' changed 23.07.2004 DIM hMidiI(MAX(0, midiInGetNumDevs-1)) AS GLOBAL DWORD ' changed 02.10.2006, 22.07.2004 DIM hMidiO(MAX(0, midiOutGetNumDevs -1)) AS GLOBAL DWORD ' changed 02.10.2006, 22.07.2004 #IF %DEF(%use_queuetimers_allways) Warning "G_LIB.DLL was compiled with the %use_queuetimers_allways flag. This mode is still experimental!" #ENDIF #IF %DEF(%choose_timer_mode) Warning "G_LIB.DLL was compiled with the %choose_timer_mode flag. This mode is still experimental!" #ENDIF #IF %DEF(%include_wavefunctions) DIM hWO(0) AS GLOBAL DWORD DIM hWI(0) AS GLOBAL DWORD #ENDIF DIM DelayNoteArray(%d16) AS GLOBAL WORD ' 02.01.2000 DIM DelayTimeArray(%d16) AS GLOBAL DWORD DIM pButnSW(11) AS GLOBAL SwitchController PTR ' only cockpit buttons sofar... DIM pButnOS(11) AS GLOBAL Oneshotcontroller PTR DIM pSlider(1) AS GLOBAL Slidercontroller PTR DIM pUDctrl(0) AS GLOBAL UpDownController PTR DIM pAudioFader(0) AS GLOBAL AudioFaderType PTR DIM pWaveFader(0) AS GLOBAL AudioFaderType PTR DIM pFunctionKey(1 TO 48) AS GLOBAL FunctionKeyController PTR '04.05.2000 DIM TiEv(0) AS GLOBAL TimedEvent '09.10.2003 DIM PicRad(%Max_NrPicRads - 1) AS GLOBAL RadarPicController '21.07.2004 #IF %DEF(%include_wavefunctions) REDIM AudioTrack0(0) AS GLOBAL DWORD ' all tracks empty on start. REDIM AudioTrack1(0) AS GLOBAL DWORD REDIM AudioTrack2(0) AS GLOBAL DWORD ' changed to DWORD 16.04.2000 REDIM AudioTrack3(0) AS GLOBAL DWORD ' contains packed integers! REDIM AudioTrack4(0) AS GLOBAL DWORD REDIM AudioTrack5(0) AS GLOBAL DWORD REDIM AudioTrack6(0) AS GLOBAL DWORD REDIM AudioTrack7(0) AS GLOBAL DWORD REDIM AudioTrack8(0) AS GLOBAL DWORD REDIM AudioTrack9(0) AS GLOBAL DWORD REDIM AudioTrackA(0) AS GLOBAL DWORD REDIM AudioTrackB(0) AS GLOBAL DWORD REDIM AudioTrackC(0) AS GLOBAL DWORD REDIM AudioTrackD(0) AS GLOBAL DWORD REDIM AudioTrackE(0) AS GLOBAL DWORD REDIM AudioTrackF(0) AS GLOBAL DWORD 'DIM AudioFormat AS GLOBAL WAVEFORMATEX ' appears also in g_glob.bi - not required here, since it's not an array ' this one is doubled in g_lib.dll AudioFormat.wFormatTag = %WAVE_FORMAT_PCM AudioFormat.nChannels = %Stereo ' declared constant AudioFormat.nSamplesPerSec = %CD_SR ' 44100 declared constant AudioFormat.wBitsPerSample = 16 ' 16 bits AudioFormat.nBlockAlign = AudioFormat.nChannels * AudioFormat.wBitsPerSample \ 8 AudioFormat.nAvgBytesPerSec = AudioFormat.nSamplesPerSec * AudioFormat.nBlockAlign AudioFormat.cbSize = %Null ' globals used for audiostreaming: ' version 5.00 - later changed to static arrays (that however costs us quite some memory...) ' REDIM Mtrack0 (%lStreamOutLatencyM1) AS GLOBAL LONG ' %d9 = 512 longs ---> 512 stereo samples or 1024 audio samples ' or 2048 bytes = %d11 so, bufferlength must be =%d11 bytes ' REDIM MTrack1 (%lStreamOutLatencyM1) AS GLOBAL LONG ' 2 integers form a L/R stereo sample ' REDIM mWbh(1) AS GLOBAL WaveHdr ' specific structures for this mixer ' should be made static as well... : StreamHdr.mWbh(0).dwUser = %MixTrack0 StreamHdr.mWbh(1).dwUser = %Mixtrack1 StreamHdr.mWbh(0).dwBufferlength = %bStreamOutLatency StreamHdr.mWbh(1).dwBufferlength = %bStreamOutLatency StreamHdr.mWbh(0).lpData = VARPTR(Stream.MTrack0(0)) ' was VARPTR(MTrack0(0)) - should now remain static! StreamHdr.mWbh(1).lpData = VARPTR(Stream.Mtrack1(0)) ' was (MTrack1(0)) 'for input streaming [14.04.2000] StrInHdr.mWbh(0).dwUser = %InTrack0 StrInHdr.mWbh(1).dwUser = %InTrack1 StrInHdr.mWbh(0).dwBufferlength = %bStreamInLatency StrInHdr.mWbh(1).dwBufferlength = %bStreamInLatency StrInHdr.mWbh(0).lpData = VARPTR(StreamIn.InTrack0(0)) StrInHdr.mWbh(1).lpData = VARPTR(StreamIn.InTrack1(0)) REDIM RecTrack((%AudioInputBufferSize \ 4)-1) AS GLOBAL DWORD RecWbh.dwUser = %False RecWbh.dwBufferlength = %AudioInputBufferSizeM1 RecWbh.lpData = VARPTR(RecTrack(0)) #ENDIF ListenMask = &H0F ' enable default lowest 4 channels of midi port 0 La = ReadDiapasonfromFile(IniFilename) GrondDo = La * (2!^(3!/12!))/64! Domq = La * (2!^(5!/24!))/64! ' quartertone lower for semitone bands in FFT's ' for convolutions and spectrum analysis: (these need the diapason!) PrepareWaveletTables Wavelets ' 19.04.2000 - Wavelets is a global type. - in g_mus.dll ' InitializeCriticalSection CritSec ' 18.03.2000 - remmed 22.12.2002 ' InitializeCriticalSection CritSecTask ' 23.03.2000 - remmed 02.12.2002 init = %True END IF ' safety check for memory allignment of listenmask: l = VARPTR(Listenmask) IF VARPTR(Listenmask2) <> l + 8 THEN MSGBOX "Memory alligment error",, FUNCNAME$ ' end of test FUNCTION = Init END FUNCTION FUNCTION Init_lib_pointers (gh AS GMT_HANDLES, App AS ApplicationType, BYREF Tk() AS Taak, BYREF Tx() AS EXTRAINFO,_ Kb AS KeyboardController, BYREF Meq() AS MidiEquipment) EXPORT AS DWORD ' ' should be called by the GMT application prior to starting up. LOCAL i AS DWORD REDIM pTask(UBOUND(Tk)) AS GLOBAL Taak PTR REDIM pTaskEx(UBOUND(pTask)) AS GLOBAL ExtraInfo PTR DIM tid(UBOUND(ptask)) AS GLOBAL DWORD ' for krl. ' retrieve the fields using @pTask(tasknr).level etc... ' we can call the procs. in GMT using the taskcodeptr in: ' @pTask(nrtask).cPtr pgh = VARPTR(gh) pApp = VARPTR(App) ' fill in defaults: FOR i = 0 TO UBOUND(Tk) pTask(i) = VARPTR(Tk(i)) pTaskEx(i) = VARPTR(Tx(i)) ' @pTask(i).naam = "" ' used for dialog button display. Names no longer than 8 characters @pTask(i).freq = 0.5 @pTask(i).level = 127 @pTask(i).pan = 64 @pTask(i).Har.vel = NUL$(128) FillHarType @pTask(i).Har @pTask(i).cPtr = %NULL ' contains the codepointer to the task code 'MAT @pTask(i).Rit.pattern() = ZER - does not work, not implemented in PB @pTask(i).Rit.pattern(0) = %NULL @pTask(i).Rit.minduur = 0.001 ' 1 ms default @pTaskEX(i).nrTexts = 12 NEXT i REDIM pMeq(UBOUND(Meq)) AS GLOBAL MidiEquipment PTR ' initial setting, should be updated later! FOR i = 0 TO UBOUND(Meq) pMeq(i) = VARPTR(Meq(i)) NEXT i pKeyboard = VARPTR(Kb) ' store pointer in DLL global ' predefine all default tasks in the scheduler ' Monitoring tasks - these are always included, if we use the default .ini file ' the task code resides in this DLL IF @pApp.WriteSeqScoreTasknr THEN @pTask(App.WriteSeqScoreTaskNr).naam = "SEQ-File" ' for score writing @pTask(App.WriteSeqScoreTaskNr).freq = 100 @pTask(App.WriteSeqScoreTaskNr).cptr = CODEPTR(WriteSeqScore) @pTask(App.WriteSeqScoreTaskNr).flags = %DLL_TASK END IF ' musical tasks ---------------------------------------------------------- ' following initialisation should be made dependent on the piece to be played/generated. ' We use code pointers in order to make the main multitasker highly portable. ' Hence, this code resides in modules such as , , , , ' , ... ' in the appropriate Init_???? procedure. IF @pApp.ShowGlobalHarmonyTaskNr THEN @pTask(App.ShowGlobalHarmonyTaskNr).naam = "ShowNote" @pTask(App.ShowGlobalHarmonyTaskNr).cptr= CODEPTR(ShowGlobhar) @pTask(App.ShowGlobalHarmonyTaskNr).freq = 16 @pTask(App.ShowGlobalHarmonyTaskNr).flags = %DLL_TASK END IF IF @pApp.GlobalHarmonyTaskNr THEN @pTask(App.GlobalHarmonyTaskNr).naam = "Global " ' keeps track of global harmony for all music tasks @pTask(App.GlobalHarmonyTaskNr).freq = 20 ' Since 15.11.98 this resides in the kernel task group. @pTask(App.GlobalHarmonyTaskNr).cptr = CODEPTR(Globhar) @pTask(App.GlobalHarmonyTaskNr).flags = %DLL_TASK END IF ' We override these defaults with composition specific code and settings ' on/after selection of an application in the main-window. i = ReadFlagDataFromFile (IniFileName) ' dll - needs the Task() structure!, so should come after ' initialisation of tasks... FUNCTION = %True END FUNCTION FUNCTION Update_MidiEquipment (BYREF Meq() AS MidiEquipment) EXPORT AS DWORD ' called from g_file in selection of equipment in listboxes LOCAL i AS DWORD REDIM pMeq(UBOUND(Meq)) AS GLOBAL MidiEquipment PTR FOR i = 0 TO UBOUND(Meq) pMeq(i)= VARPTR(Meq(i)) NEXT i FUNCTION = %True END FUNCTION SUB Publish_MM (BYVAL MenM AS DWORD, BYVAL siz AS DWORD) EXPORT ' 16.01.2005 ' note that we cannot pass arrays of pointers byref!, hence this construction. ' MenM is passed as the dword varptr of MM(0) !!! REDIM MM(siz) AS GLOBAL musician PTR AT MenM ' this has been double checked by gwr!!! END SUB SUB Debugdummy() EXPORT END SUB ' [EOF]