' randomMIDInoises3.bas nomainwin WindowWidth =400 WindowHeight =280 global voice, velocity, level, dwMsg, hMidiOut dim voice$( 128) for i =0 to 127 read i$ voice$( i) =i$ next i textbox #w.tb1, 10, 10, 170, 80 textbox #w.tb2, 200, 40, 80, 50 textbox #w.tb3, 300, 40, 80, 50 textbox #w.tb4, 10, 140, 370, 50 statictext #w.st1, " Pitch Voice Level", 20, 100, 360, 40 button #w.b1, "Voice change", voice, LR, 220, 20, 80, 30 open "Random MIDI player" for window as #w #w.tb1, "!font courier_bold 48" #w.tb2, "!font courier_bold 24" #w.tb3, "!font courier_bold 24" #w.tb4, "!font courier_bold 24" #w.st1, "!font courier_bold 12" #w, "trapclose [quit]" struct midi, midiptr$ As ptr CallDLL #winmm, "midiOutOpen", midi As struct, -1 As long, 0 As long, 0 As long, 0 As long, ret As long hMidiOut =midi.midiptr$.struct 'handle to midi device channel = 2 level = 50 voice = 0 velocity =127 [main] note =38 +int( 60 *rnd(1)) level =10 +int( 100 *rnd(1)) #w.tb1, using( "###", note) #w.tb2, using( "###", voice) #w.tb3, using( "###", level) #w.tb4, " "; voice$( voice) dwMsg =( 143 +channel) +note *256 +level *256*256 'Send command to play sound... CallDLL #winmm, "midiOutShortMsg", hMidiOut As ulong, dwMsg As ulong, ret As ulong for jhf =0 to ( 10000 +200000*rnd(1)): next jhf 'Some delay dwMsg =( 143 +channel) +note *256 +0 '... then turn sound off. CallDLL #winmm, "midiOutShortMsg", hMidiOut As ulong, dwMsg As ulong, ret As ulong scan goto [main] [quit] 'Close the MIDI output device CallDLL #winmm, "midiOutClose", hMidiOut As ulong, ret As ulong close #w end '_____________________________________________________________________________________________ sub voice voicehandle$ 'event is change channel 2, (191+2 =193) voice =int( 127 *rnd( 1)) velocity =127 dwMsg =193 +voice*256 +0 CallDLL #winmm, "midiOutShortMsg", hMidiOut As ulong, dwMsg As ulong, ret As ulong end sub 'list of 128 voices, in order of their MIDI indexes Data "Grand Piano","Bright Grand","Electric Grand","Honky Tonk" Data "Rhodes","Chorus Piano","Harpsichord","Clavinet" Data "Celesta","Glockenspiel","Music Box","Vibraphone" Data "Marimba","Xylophone","Tubular Bells","Dulcimer" Data "Hammond Organ","Percussion Organ","Rock Organ" Data "Church Organ","Reed Organ","Accordian","Harmonica" Data "Tango Accordian","Accoustic Nylon Guitar" Data "Accoustic Steel Guitar","Electric Jazz Guitar" Data "Electric Clean Guitar","Electric Mute Guitar" Data "Overdrive Guitar","Distorted Guitar","Guitar Harmonic" Data "Accoustic Bass","Electric Bass Finger","Electric Bass Pick" Data "Fretless Bass","Slap Bass One","Slap Bass Two" Data "Synth Bass One","Synth Bass Two","Violin","Viola","Cello" Data "Contrabass","Tremolo Strings","Pizzicato Strings" Data "Orchestra Harp","Timpani","String Ensemble One" Data "String Ensemble Two","Synth Strings One","Synth Strings Two" Data "Choir Ahhs","Voice Oohs","Synth Voice","Orchestra Hit" Data "Trumpet","Trombone","Tuba","Mute Trumpet","French Horn" Data "Brass Section","Synth Brass One","Synth Brass Two" Data "Soprano Sax","Alto Sax","Tenor Sax","Bari Sax","Oboe" Data "English Horn","Bassoon","Clarinet","Piccolo","Flute" Data "Recorder","Pan Flute","Bottle Blow","Shakuhachi","Whistle" Data "Ocarina","Square Wave","Sawtooth","Caliope","Chiff Lead" Data "Charang","Solo Synth VX","Brite Saw","Brass and Lead" Data "Fantasia Pad","Warm Pad","Poly Synth Pad","Space Vox Pad" Data "Bowd Glas Pad","Metal Pad","Halo Pad","Sweep Pad" Data "Ice Rain","Sound Track","Crystal","Atmosphere","Brightness" Data "Goblin","Echo Drops","Star Theme","Sitar","Banjo","Shamisen" Data "Koto","Kalimba","Bagpipe","Fiddle","Shanai" Data "Tinkle Bell","Agogo","Steel Drums","Wood Block","Taiko Drum" Data "Melodic Tom","Synth Drum","Rev Cymbal" Data "Guitar Fret Noise","Breath Noise","Sea Shore","Bird Tweet" Data "Phone Ring","Helicopter","Applause","Gunshot"