10-09-2008, 07:41 PM
Hey Vig,
Inspired by your synth...made a little sample playback keyboard based on yours:
Macro QM_Soundbank_Macro
Function QM_Soundbank_Dlg
To test, put the "soundbank" folder (download zip file -- 1.57MB) on the desktop. More sample soundbanks can be added simply by creating a new subfolder in the soundbank folder with wav files named 1.wav - thru -13.wav (for keys C to C octave). Any new soundbank subfolders are automatically picked up by the macro and added to the drop-down soundbank selector.
Steve
Inspired by your synth...made a little sample playback keyboard based on yours:
Macro QM_Soundbank_Macro
str+ sbdir = "$desktop$\soundbank\"
str background.from(sbdir "background.jpg")
str sbdir_all.from(sbdir "*.*")
str+ sb = "piano"
str+ changebank
str sb_selected
str controls = "16 15"
str cb16 sb15bac
sb15bac = background
;=enumerate soundbank directorys=
Dir d
foreach(d sbdir_all FE_Dir 1)
,str sPath=d.FileName(0)
,_s.format("%s%s[91][93]" _s sPath)
_s.rtrim("[91][93]")
out _s
;DLG_LOOP
changebank = "no"
cb16 = _s
sb_selected.from("&" sb)
cb16.replacerx(sb sb_selected)
cb16.escape(0)
if(!ShowDialog("QM_Soundbank_Dlg" &QM_Soundbank_Dlg &controls)) ret
;=point to new wav directory and reinit dlg=
if changebank = "yes"
,goto DLG_LOOP
endFunction QM_Soundbank_Dlg
;\Dialog_Editor
function# hDlg message wParam lParam
str whitekey.from(sbdir "white.jpg")
str blackkey.from(sbdir "black.jpg")
str snd1.from(sbdir sb "\1.wav")
str snd2.from(sbdir sb "\2.wav")
str snd3.from(sbdir sb "\3.wav")
str snd4.from(sbdir sb "\4.wav")
str snd5.from(sbdir sb "\5.wav")
str snd6.from(sbdir sb "\6.wav")
str snd7.from(sbdir sb "\7.wav")
str snd8.from(sbdir sb "\8.wav")
str snd9.from(sbdir sb "\9.wav")
str snd10.from(sbdir sb "\10.wav")
str snd11.from(sbdir sb "\11.wav")
str snd12.from(sbdir sb "\12.wav")
str snd13.from(sbdir sb "\13.wav")
if(hDlg) goto messages
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 167 143 "QM Soundbank"
;11 Button 0x54038080 0x0 92 24 14 70 ""
;10 Button 0x54038080 0x0 74 24 14 70 ""
;9 Button 0x54038080 0x0 38 24 14 70 ""
;8 Button 0x54038080 0x0 20 24 14 70 ""
;3 Button 0x54038080 0x0 10 24 18 108 ""
;4 Button 0x54038080 0x0 28 24 18 108 ""
;5 Button 0x54038080 0x0 46 24 18 108 ""
;6 Button 0x54038080 0x0 64 24 18 108 ""
;7 Button 0x54038080 0x0 82 24 18 108 ""
;12 Button 0x54038080 0x0 112 24 14 70 ""
;13 Button 0x54038080 0x0 100 24 18 108 ""
;14 Button 0x54038080 0x0 118 24 20 108 ""
;17 Button 0x54038080 0x0 138 24 20 108 ""
;16 ComboBox 0x54230243 0x0 62 6 96 213 ""
;15 Static 0x5400000E 0x20000 0 0 194 174 "back"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,;DT_Init(hDlg lParam)
,int white=qm.LoadPictureFile(whitekey 0)
,SendMessage(id(3 hDlg) BM_SETIMAGE IMAGE_BITMAP white)
,SendMessage(id(4 hDlg) BM_SETIMAGE IMAGE_BITMAP white)
,SendMessage(id(5 hDlg) BM_SETIMAGE IMAGE_BITMAP white)
,SendMessage(id(6 hDlg) BM_SETIMAGE IMAGE_BITMAP white)
,SendMessage(id(7 hDlg) BM_SETIMAGE IMAGE_BITMAP white)
,SendMessage(id(13 hDlg) BM_SETIMAGE IMAGE_BITMAP white)
,SendMessage(id(14 hDlg) BM_SETIMAGE IMAGE_BITMAP white)
,SendMessage(id(17 hDlg) BM_SETIMAGE IMAGE_BITMAP white)
,
,int black=qm.LoadPictureFile(blackkey 0)
,SendMessage(id(8 hDlg) BM_SETIMAGE IMAGE_BITMAP black)
,SendMessage(id(9 hDlg) BM_SETIMAGE IMAGE_BITMAP black)
,SendMessage(id(10 hDlg) BM_SETIMAGE IMAGE_BITMAP black)
,SendMessage(id(11 hDlg) BM_SETIMAGE IMAGE_BITMAP black)
,SendMessage(id(12 hDlg) BM_SETIMAGE IMAGE_BITMAP black)
,case WM_DESTROY
,DT_DeleteData(hDlg)
,DeleteObject(SendMessage(id(3 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(4 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(5 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(6 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(7 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(8 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(9 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(10 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(11 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(12 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(13 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(14 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,DeleteObject(SendMessage(id(17 hDlg) BM_GETIMAGE IMAGE_BITMAP 0))
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3 ;; C
,,bee snd1
,case 8 ;; C#/Db
,,bee snd2
,case 4 ;; D
,,bee snd3
,case 9 ;; D#/Eb
,,bee snd4
,case 5 ;; E
,,bee snd5
,case 6 ;; F
,,bee snd6
,case 10 ;; F#/Gb
,,bee snd7
,case 7 ;; G
,,bee snd8
,case 11 ;; G#/Ab
,,bee snd9
,case 13 ;; A
,,bee snd10
,case 12 ;; A#/Bb
,,bee snd11
,case 14 ;; B
,,bee snd12
,case 17 ;; C 8va
,,bee snd13
,case CBN_SELENDOK<<16|16
,,,if(CB_SelectedItem(id(16 hDlg) sb) >= 0)
,,,,changebank = "yes"
,,,,DT_Ok hDlg
,case IDOK
,case IDCANCEL
ret 1To test, put the "soundbank" folder (download zip file -- 1.57MB) on the desktop. More sample soundbanks can be added simply by creating a new subfolder in the soundbank folder with wav files named 1.wav - thru -13.wav (for keys C to C octave). Any new soundbank subfolders are automatically picked up by the macro and added to the drop-down soundbank selector.
Steve
