' beiaardsysx.bas ' logosoft 2006 ' creates a .syx for the midi controllerd carillon to change it's velocity mapping. minimum and maximum pulse duration are up to the user #OPTION VERSION3 'win 95 or higher #COMPILE EXE #DIM ALL #INCLUDE "../winapi/win32api.inc" #INCLUDE "../winapi/CommCtrl.inc" GLOBAL hTrck AS DWORD DECLARE CALLBACK FUNCTION cbm FUNCTION PBMAIN () AS LONG LOCAL hw AS DWORD LOCAL n AS DWORD DIALOG NEW 0, "BeiaardSyx", 100, 100, 200, 110, %WS_POPUP OR %WS_CAPTION OR %WS_SYSMENU OR %DS_3DLOOK OR %DS_CENTER OR %DS_MODALFRAME TO hw CONTROL ADD LABEL, hw, -1, "Midi noot:", 1,1, 40, 12 CONTROL ADD TEXTBOX, hw, 1, "", 45, 1, 30, 12, %ES_NUMBER OR %WS_BORDER OR %WS_TABSTOP, %WS_EX_CLIENTEDGE CONTROL ADD LABEL, hw, -1, "Progchange [122-127]:", 85, 1, 80, 12 CONTROL ADD TEXTBOX, hw, 2, "122", 170, 1, 30, 12, %ES_NUMBER OR %WS_BORDER OR %WS_TABSTOP, %WS_EX_CLIENTEDGE CONTROL ADD LABEL, hw, -1, "Ticks (19.2 microseconden) voor velocity 1:", 1, 14, 150, 12 CONTROL ADD TEXTBOX, hw, 3, "", 155, 14, 30, 12, %ES_NUMBER OR %WS_BORDER OR %WS_TABSTOP, %WS_EX_CLIENTEDGE CONTROL ADD LABEL, hw, -1, "Ticks (19.2 microseconden) voor velocity 127:", 1, 27, 150, 12 CONTROL ADD TEXTBOX, hw, 4, "", 155, 27, 30, 12, %ES_NUMBER OR %WS_BORDER OR %WS_TABSTOP, %WS_EX_CLIENTEDGE CONTROL ADD LABEL, hw, -1, "Curve:", 1, 41, 40, 12 CONTROL ADD GRAPHIC, hw, 5, "", 42, 41, 83, 40 GRAPHIC ATTACH hw, 5 GRAPHIC PAINT (1, 1), 0 CONTROL ADD "msctls_trackbar32", hw, 6, "curve", 127, 38, 12, 44, %WS_CHILD OR %WS_VISIBLE OR %TBS_VERT OR %TBS_NOTICKS CONTROL HANDLE hw, 6 TO htrack SendMessage htrack, %TBM_SETRANGE, -100, 100 CONTROL ADD BUTTON, hw, 10, "&go", 1, 85, 64, 12, %BS_DEFAULT CONTROL ADD BUTTON, hw, 11, "&help", 67, 85, 64, 12 CONTROL ADD BUTTON, hw, 12, "e&xit", 133, 85, 64, 12 DIALOG SHOW MODELESS hw, CALL CBM DO DIALOG DOEVENTS TO n LOOP WHILE n END FUNCTION CALLBACK FUNCTION CBM LOCAL noot AS BYTE LOCAL prg AS BYTE LOCAL minticks AS LONG, maxticks AS LONG LOCAL b$ LOCAL sysx$ LOCAL vel AS BYTE LOCAL ms4vel AS LONG LOCAL lsb AS BYTE LOCAL msb AS BYTE LOCAL f AS LONG IF CBMSG <> %WM_COMMAND THEN EXIT FUNCTION IF CBCTLMSG = %BN_CLICKED THEN SELECT CASE CBCTL CASE 10 CONTROL GET TEXT CBHNDL, 1 TO b$ noot = VAL(b$) IF noot <= 0 OR noot > 127 THEN MSGBOX "Check value for note!" + $CRLF + "The note should be ginven as midi note number! (1-127)",,"Check input": EXIT FUNCTION CONTROL GET TEXT CBHNDL, 2 TO b$ prg = VAL(b$) IF prg < 122 OR prg > 127 THEN MSGBOX "Progchange should be between 122 and 127!",,"Check input": EXIT FUNCTION CONTROL GET TEXT CBHNDL, 3 TO b$ minticks = VAL(b$) IF minticks <= 0 THEN MSGBOX "Illegal value for velocity 1, should be > 0!",,"Check input": EXIT FUNCTION IF minticks > 5208 THEN MSGBOX "Illegal value for velocity 1, 5208 (which corresponds to 100ms!) is the maximum!",,"Check input": EXIT FUNCTION CONTROL GET TEXT CBHNDL, 4 TO b$ maxticks = VAL(b$) IF maxticks <= minticks THEN MSGBOX "Ticks for velocity 127 should be more then for velocity 1!",,"Check input": EXIT FUNCTION IF maxticks > 5208 THEN MSGBOX "Illegal value for velocity 1, 5208 (which corresponds to 100ms!) is the maximum!",,"Check input": EXIT FUNCTION sysx$ = CHR$(&HF0, &H7D) + "klok" + CHR$(0) + CHR$(prg) + CHR$(noot) + CHR$(0, 0) FOR vel = 1 TO 127 ms4vel = minticks + (maxticks - minticks) * (vel/127) lsb = ms4vel AND &H7F SHIFT RIGHT ms4vel, 7 msb = ms4vel AND &H7F 'Velocity n TIMER MSB + Velocity n TIMER LSB - 14 BIT TIMER resolution sysx$ = sysx$ + CHR$(msb) + CHR$(lsb) NEXT sysx$ = sysx$ + CHR$(&HF7) f = FREEFILE OPEN "noot" + TRIM$(STR$(noot)) + "pg" + TRIM$(STR$(prg)) + ".syx" FOR BINARY ACCESS WRITE LOCK WRITE AS f PUT$ f, sysx$ CLOSE# f MSGBOX "The file 'noot" + TRIM$(STR$(noot)) + "pg" + TRIM$(STR$(prg)) + ".syx' is created!",,"BeiaardSyx" CASE 11 b$ = "With this program you can create a .syx file with the commands to control the velocity response of the carillon, for one note in one program at a time." + $CRLF b$ = b$ + "You can upload this .syx file to the beiaard with anynnormal midi sequencing program." + $CRLF b$ = b$ + "You can upload 5 different programs (122 up to 127), which you later can select by sending the carillon a standard Program Change message from your midi sequencer." + $CRLF + $CRLF b$ = b$ + "This means in fact that you have to create a separate sysex file for each note and for each program change you want to use." + $CRLF b$ = b$ + "(Often one default scaling will be enough, that's why it defaults to 122, but if you want to compare different scalings, you can)" + $CRLF b$ = b$ + "IMPORTANT: if you send different .syx files in a row, make sure to wait at least three seconds in between the end of one and the start of another!" + $CRLF + $CRLF b$ = b$ + "You need to supply the following parameters:" + $CRLF b$ = b$ + " - The note (as a midi number) for which you want to program the velocity response." + $CRLF b$ = b$ + " - The Program Change nr you wish to fill in." + $CRLF b$ = b$ + " - The number of ticks the magnet should be held when using a velocity of 1" + $CRLF b$ = b$ + " Each tick corresponds to 19.2 microseconds, so if you want to hold the magnet for 2 ms, " + $CRLF b$ = b$ + " apply this formula: (2 * 1000)/19.2 = 104 (round the value to the nearest integer)." + $CRLF b$ = b$ + " So, if we want the magnet to be held for 2 ms when we use velocity 1, we have to fill in 104 here." + $CRLF b$ = b$ + " - The number of ticks the magnet should be held when using a velocity of 127. " + $CRLF b$ = b$ + " Be carefull: dependant on the type of magnets you use and the voltage you feed them," + $CRLF b$ = b$ + " a too high value can burn your magnets!" + $CRLF b$ = b$ + " The program will automatically calculate the nr of ticks for all velocities in between 1 and 127." MSGBOX b$,, "BeiaardSyx help" CASE 12 DIALOG END CBHNDL END SELECT END IF END FUNCTION