'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 1 October 2004 at 1:59:05 am'! "Change Set: MidiEnhancements Date: 1 October 2004 Author: Markus Gaelli Some enhancements for MIDI. Now you can write code like: |aPort| aPort:= self openOnPortNumber: 0. [aPort useInstrument: 'Woodblock' onChannel: 0. aPort playNoteNamed: 'c4' onChannel: 0. (Delay forMilliseconds: 250) wait. aPort stopNoteNamed: 'c4' onChannel: 0] ensure: [aPort close]"! !SimpleMIDIPort methodsFor: 'open/close'! useInstrument: aName onChannel: aChannel self useInstrumentNumber: (self class midiInstruments indexOf: aName)-1 onChannel: aChannel! ! !SimpleMIDIPort methodsFor: 'open/close'! useInstrumentNumber: aNumber onChannel: aChannel self ensureOpen. self midiCmd: 192 channel: aChannel byte: aNumber ! ! !SimpleMIDIPort methodsFor: 'primitives' stamp: 'mga 10/1/2004 01:49'! playNote: aNote onChannel: aChannel self playNote: aNote velocity: 64 onChannel: aChannel! ! !SimpleMIDIPort methodsFor: 'primitives'! playNote: aNote velocity: aVel onChannel: aChannel self midiCmd: 144 channel: aChannel byte: aNote byte: aVel! ! !SimpleMIDIPort methodsFor: 'primitives' stamp: 'mga 10/1/2004 01:52'! playNoteNamed: aNotename onChannel: aChannel self playNoteNamed: aNotename velocity: 64 onChannel: aChannel! ! !SimpleMIDIPort methodsFor: 'primitives'! playNoteNamed: aNotename velocity: aVel onChannel: aChannel self playNote: (AbstractSound midiKeyForPitch: aNotename) velocity: aVel onChannel: aChannel ! ! !SimpleMIDIPort methodsFor: 'primitives' stamp: 'mga 10/1/2004 01:50'! stopNote: aNote onChannel: aChannel self stopNote: aNote velocity: 64 onChannel: aChannel! ! !SimpleMIDIPort methodsFor: 'primitives'! stopNote: aNote velocity: aVel onChannel: aChannel self midiCmd: 128 channel: aChannel byte: aNote byte: aVel! ! !SimpleMIDIPort methodsFor: 'primitives' stamp: 'mga 10/1/2004 01:50'! stopNoteNamed: aNotename onChannel: aChannel self stopNoteNamed: aNotename velocity: 64 onChannel: aChannel! ! !SimpleMIDIPort methodsFor: 'primitives'! stopNoteNamed: aNotename velocity: aVel onChannel: aChannel self stopNote: (AbstractSound midiKeyForPitch: aNotename) velocity: aVel onChannel: aChannel ! ! !SimpleMIDIPort class methodsFor: 'utilities'! midiInstruments "self midiInstruments" ^ #('Acoustic Grand Piano' 'Bright Acoustic Piano' 'Electric Grand Piano' 'Honky-tonk Piano' 'Rhodes Piano' 'Chorused Piano' 'Harpsichord' 'Clavinet' 'Celesta' 'Glockenspiel' 'Music box' 'Vibraphone' 'Marimba' 'Xylophone' 'Tubular Bells' 'Dulcimer' 'Hammond Organ' 'Percussive Organ' 'Rock Organ' 'Church Organ' 'Reed Organ' 'Accordian' 'Harmonica' 'Tango Accordian' 'Acoustic Guitar (nylon)' 'Acoustic Guitar (steel)' 'Electric Guitar (jazz)' 'Electric Guitar (clean)' 'Electric Guitar (muted)' 'Overdriven Guitar' 'Distortion Guitar' 'Guitar Harmonics' 'Acoustic Bass' 'Electric Bass (finger)' 'Electric Bass (pick)' 'Fretless Bass' 'Slap Bass 1' 'Slap Bass 2' 'Synth Bass 1' 'Synth Bass 2' 'Violin' 'Viola' 'Cello' 'Contrabass' 'Tremolo Strings' 'Pizzicato Strings' 'Orchestral Harp' 'Timpani' 'String Ensemble 1' 'String Ensemble 2' 'Synth Strings 1' 'Synth Strings 2' 'Choir Aahs' 'Voice Oohs' 'Synth Voice' 'Orchestra Hit' 'Trumpet' 'Trombone' 'Tuba' 'Muted Trumpet' 'French Horn' 'Brass Section' 'Synth Brass 1' 'Synth Brass 2' 'Soprano Sax' 'Alto Sax' 'Tenor Sax' 'Baritone Sax' 'Oboe' 'English Horn' 'Bassoon' 'Clarinet' 'Piccolo' 'Flute' 'Recorder' 'Pan Flute' 'Bottle Blow' 'Shakuhachi' 'Whistle' 'Ocarina' 'Lead 1 (square)' 'Lead 2 (sawtooth)' 'Lead 3 (caliope lead)' 'Lead 4 (chiff lead)' 'Lead 5 (charang)' 'Lead 6 (voice)' 'Lead 7 (fifths)' 'Lead 8 (brass + lead)' 'Pad 1 (new age)' 'Pad 2 (warm)' 'Pad 3 (polysynth)' 'Pad 4 (choir)' 'Pad 5 (bowed)' 'Pad 6 (metallic)' 'Pad 7 (halo)' 'Pad 8 (sweep)' 'FX 1 (rain)' 'FX 2 (soundtrack)' 'FX 3 (crystal)' 'FX 4 (atmosphere)' 'FX 5 (brightness)' 'FX 6 (goblins)' 'FX 7 (echoes)' 'FX 8 (sci-fi)' 'Sitar' 'Banjo' 'Shamisen' 'Koto' 'Kalimba' 'Bagpipe' 'Fiddle' 'Shanai' 'Tinkle Bell' 'Agogo' 'Steel Drums' 'Woodblock' 'Taiko Drum' 'Melodic Tom' 'Synth Drum' 'Reverse Cymbal' 'Guitar Fret Noise' 'Breath Noise' 'Seashore' 'Bird Tweet' 'Telephone Ring' 'Helicopter' 'Applause' 'Gunshot' )! ! !SimpleMIDIPort class methodsFor: 'utilities'! percussionInstruments "self percussionInstruments" ^ #('Bottle Blow' 'Shakuhachi' 'Whistle' 'Ocarina' 'Lead 1 (square)' 'Lead 2 (sawtooth)' 'Lead 3 (caliope lead)' 'Lead 4 (chiff lead)' 'Lead 5 (charang)' 'Lead 6 (voice)' 'Lead 7 (fifths)' 'Lead 8 (brass + lead)' 'Pad 1 (new age)' 'Pad 2 (warm)' 'Pad 3 (polysynth)' 'Pad 4 (choir)' 'Pad 5 (bowed)' 'Pad 6 (metallic)' 'Pad 7 (halo)' 'Pad 8 (sweep)' 'FX 1 (rain)' 'FX 2 (soundtrack)' 'FX 3 (crystal)' 'FX 4 (atmosphere)' 'FX 5 (brightness)' 'FX 6 (goblins)' 'FX 7 (echoes)' 'FX 8 (sci-fi)' 'Sitar' 'Banjo' 'Shamisen' 'Koto' 'Kalimba' 'Bagpipe' 'Fiddle' 'Shanai' 'Tinkle Bell' 'Agogo' 'Steel Drums' 'Woodblock' 'Taiko Drum' 'Melodic Tom' 'Synth Drum' 'Reverse Cymbal' 'Guitar Fret Noise' 'Breath Noise' 'Seashore' 'Bird Tweet' 'Telephone Ring' 'Helicopter' 'Applause' 'Gunshot' )! ! !SimpleMIDIPort class methodsFor: 'examples' stamp: 'mga 10/1/2004 01:51'! examplePlayNoteNamedVelocityOnChannel "self examplePlayNoteNamedVelocityOnChannel" |aPort| aPort:= self openOnPortNumber: 0. #('Bottle Blow' 'Shakuhachi' 'Whistle' 'Ocarina' 'Lead 1 (square)' 'Lead 2 (sawtooth)' 'Lead 3 (caliope lead)' 'Lead 4 (chiff lead)' 'Lead 5 (charang)' 'Lead 6 (voice)' 'Lead 7 (fifths)' 'Lead 8 (brass + lead)' 'Pad 1 (new age)' 'Pad 2 (warm)' 'Pad 3 (polysynth)' 'Pad 4 (choir)' 'Pad 5 (bowed)' 'Pad 6 (metallic)' 'Pad 7 (halo)' 'Pad 8 (sweep)' 'FX 1 (rain)' 'FX 2 (soundtrack)' 'FX 3 (crystal)' 'FX 4 (atmosphere)' 'FX 5 (brightness)' 'FX 6 (goblins)' 'FX 7 (echoes)' 'FX 8 (sci-fi)' 'Sitar' 'Banjo' 'Shamisen' 'Koto' 'Kalimba' 'Bagpipe' 'Fiddle' 'Shanai' 'Tinkle Bell' 'Agogo' 'Steel Drums' 'Woodblock' 'Taiko Drum' 'Melodic Tom' 'Synth Drum' 'Reverse Cymbal' 'Guitar Fret Noise' 'Breath Noise' 'Seashore' 'Bird Tweet' 'Telephone Ring' 'Helicopter' 'Applause' 'Gunshot' ) do: [:anInstrumentName | [aPort useInstrument: anInstrumentName onChannel: 0. aPort playNoteNamed: 'c4' onChannel: 0. (Delay forMilliseconds: 250) wait. aPort stopNoteNamed: 'c4' onChannel: 0] ensure: [aPort close]]! !