Joystick for MIDI

Rick Cocker

Rick Cocker was one of our reviewers of the Music 2000 MIDI interface in AMPLINEX 005 (May 1988).

Music 2000 MIDI interface owners should use:

*EXEC U.MIDIjoy

to read this file into AMPLE. It should then be RUN.

% List of words

"RUN" [] "button" [] "harp" []

"info" [] "info2" [] "info3" []

"info4" [] "info5" [] "info6" []

"joyval" [] "mix" [] "mod" []

"play" [] "sig" [] "sus" []

"swait" [] "uilleann" [] "velact" []

"RUN" [7MODE 6FOR(NL)FOR DISPLAY

% Filename: U.MIDIjoy

%

% Demonstration using the joystick to

% control MIDI and velocity functions.

%

% The piece used is an Irish

% traditional ballad called

% "Eileen Aroon".

%

% Press ESCAPE to end and type

% 'info' for further details.

%

READY 115=T mix sig play

]

"button" [

% test and get value of joystick

% button. Note that this word is not

% active in this piece but included to

% show method.

0 &80 &FFF4 CODE #2 % get value

3 AND #11 % test for

1 #= % button 1 (use 0

% if button 0 )

IF( #11 % if button on

64 MIDICONTROL )IF % then send

% sustain

#2 % discard value

]

"harp" [% harp accompaniment

velact % set velocity on joystick

24,4FOR(-2:FACFACFcafca)FOR gBDGBD

4FOR(-2:FACFACFcafca)FOR

gBDGBD!fACFACFcafcaBDFBDa!gBDGDb

!-eB-EG-Eb!cGCGEc!dADADF!!-eB-EB-EG

!!cGCEGCEGCgec!fACFAC!gBDGBD

2FOR(-2:FACFACFcafca)FOR gBDGBD

!fACFACFcafcaf///^

]

"info" [7MODE 4FOR(NL)FOR DISPLAY

% In this piece the joystick is used

% to control two functions - velocity

% and modulation-wheel effects.

%

% Joysticks work in different ways but

% these simple examples can be used as

% starting points. The programming can

% be much improved as it is included

% here purely for demonstration.

%

% Note that the velocity word if

% scaled 0-64 could be used by Music

% 5000 voices.

%

% ** Press SPACE BAR to continue **

#IN #2 info2

]

"info2" [7MODE 4FOR(NL)FOR DISPLAY

% Both axes are being used but in

% different ways:

%

% 1) The horizontal axis controls

% velocity (=L) using the ACT command

% found in the word 'velact' placed

% prior to the 'harp' music in part 1.

%

% 2) The vertical axis is controlling

% modulation effects found in the word

% 'mod'. In this piece I am using

% SHARE to place the modulation effect

% on part 2.

%

% ** Press SPACE BAR to continue **

#IN #2 info3

]

"info3" [7MODE 4FOR(NL)FOR DISPLAY

% I have placed the word 'mod' after

% the play (P) structure to show that

% it can be used on the non-playing

% part. This would leave all playing

% parts for music notation. It could

% of course be used in a normal part.

%

% Although not used in this piece I

% have included the word 'button'

% which tests to see if the

% joystick's fire-button is being

% pressed. When pressed it turns on

% the instruments' sustain.

%

% ** Press SPACE BAR to continue **

#IN #2 info4

]

"info4" [7MODE 4FOR(NL)FOR DISPLAY

% Note: any MIDI control, which uses a

% flag (ON/OFF) to activate it, may be

% controlled by the fire-button.

%

% Likewise, any MIDI control with a

% data value 0-127 may be controlled

% by the joystick e.g. Breath control,

% Velocity, Portamento Time. You can

% also send out system-exclusive data

% e.g. Glide-time on a Casio CZ.

% However, if the instrument is slow

% to respond to some commands it could

% give rise to synching problems.

%

% ** Press SPACE BAR to continue **

#IN #2 info5

]

"info5" [7MODE 4FOR(NL)FOR DISPLAY

% Note: The values produced by joyval

% are 0-126. 0 is produced instead of

% 127 because of AMPLE's use of 16-bit

% signed integers. To stop this use:

%

% "store"[GVAR] % old value store

% "joyval"[&80 &FFF4 CODE #2 512 #/ #2

% #11 0 #= IF( % If 0 compare to

% store #? SIGN #= % old value's SIGN

% IF(0)ELSE(-1)IF % neg? =0 pos? =-1

% )IF #11 store #! % store it.

% #11 SIGN IF(-1 #* 127 XOR )IF ]

%

% ** Press SPACE BAR to continue **

#IN #2 info6

]

"info6" [7MODE 4FOR(NL)FOR DISPLAY

% I have been unable to obtain 127 at

% the highest end of the joystick! Can

% anyone solve this? Joysticks are

% unreliable when at extremes. Is all

% that clear? Ah well...

%

% AMPLINEX has shown that there are

% many good music programmers using

% AMPLE so please experiment and if

% you come up with useful routines

% post them off. Adding real-time

% sound control to the Hybrid Music

% System for me offers many exciting

% possibilities.

%

% Rick Cocker (April 1988)

]

"joyval" [

% axisnumber joyval -> valuenumber

swait

&80 &FFF4 CODE #2 % get value

512 #/ #2 % scale to 63 to -64

#11 SIGN % test for negative

IF( -1 #* 127 XOR )IF

% scale to 64 to 126

]

"mix" [% set up mix for MIDI voices

1 SHARE 8 VOICES MIDIV 1 MIDICHANNEL

2 SHARE 8 VOICES MIDIV 2 MIDICHANNEL

PNUM SHARE

]

"mod" [% takes vertical joystick value

% for modulation control

2 SHARE % share with part2

REP(

REP( IDLE % pass control to

% other players

2 joyval #11 % get joystick value

1 MIDICONTROL % set control

)UNTIL( )REP

)REP

]

"play" [% play 2 parts

1 P( harp )P % includes ACT command

% "velact" for velocity

2 P( uilleann )P

GO

mod % modulation on part2

]

"sig" [K(-B)K

]

"sus" [% flag sus

64 MIDICONTROL % if ON (-1) turn

% sustain control on

]

"swait" [% waits until last DURATION

% (or music event) complete

REP( QTIME 0 #< )UNTIL( IDLE )REP

]

"uilleann" [% uilleann pipe plays tune

288,/ 48,

0:F12,//G/f/d/|c/////F/G/fG|48,A

//|///|c/D|F12,//G/48,A|g12,//Agf/d/

|48,F12,//G/f/d/|48,c//|F12,//G/f/d/

|48,c12,//F/G/fG|48,A//|///|A/g|f12,

//G/48,A|g12,//Agf/e/|48,F//|^FA|B/

a|g/d|-E12,//F/-e/d/|48,c//|12,G/fG

48,A12,d///|48,-E12,//F/-e/d/|48,c//

|12,////48,//|12,A/gAC/D/c/a/|f/d/c/

D/F/G/|48,A//|///|c/D|F12,//G/48,A|g

12,//Agf/e/|48,F//|0,^

]

"velact" [% set ACT to receive

% joystick value and put on velocity

% only if gate is on

30 ACT(

5 FVAR #? % get gate voice

6 FVAR #? % get gate value

AND % voice number if ON gate

VOICE % OFF if OFF GATE/no gate

1 joyval =L % set new velocity value

ACT )ACT

]