File: midishrc

package info (click to toggle)
midish 0.2.5-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 760 kB
  • ctags: 1,294
  • sloc: ansic: 13,035; makefile: 119; sh: 114
file content (338 lines) | stat: -rw-r--r-- 5,696 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
#
# midi devices config
#
#devattach 0 "/dev/rmidi4"
#devattach 1 "/dev/rmidi3"

#
# set the current input channel
#
proc ci input {
	songsetcurinput $input
}

#
# set the current channel
#
proc cc chan {
	songsetcurchan $chan
}

#
# set the current filt
#
proc cf filt { 
	songsetcurfilt $filt
}

#
# set the current track
#
proc ct track { 
	songsetcurtrack $track
}

#
# create a channel and a filter
#
proc ni name chan {
	songsetcurtrack nil
	filtnew $name 
	channew $name $chan
	filtchanmap $name [songgetcurinput] $name
}

#
# create a new filter 
#
proc nf filt { 
	filtnew $filt
}

#
# create a new track 
#
proc nt name { 
	tracknew $name 
}

#
# some filter rules
#
proc ctldrop ic {
	filtctldrop [songgetcurfilt] [songgetcurinput] $ic
}
proc ctlmap ic oc {
	filtctlmap [songgetcurfilt] [songgetcurinput] [songgetcurchan] $ic $oc
}
proc transpose halftones {
	filtkeymap [songgetcurfilt] [songgetcurinput] [songgetcurchan] 0 127 $halftones
}

#
# do nothing, just echo trough the configuration of the current track
#
proc i  {
	songidle;
}

#
# play the song
#
proc p  {
	metroswitch 0
	songplay
}

#
# record a track while playing the song, start 1 measure before
# the current position
#
proc r  { 
	metroswitch 1
	songrecord
}

#
# print the list of tracks, channels and filters, etc
#
proc l  {
	songinfo
}

#
# change current position
#
proc g measure {
	songsetcurpos $measure
}

#
# change the current selection's length
#
proc sel length {
	songsetcurlen $length
}

#
# set note quantum
#
proc n denom {
	songsetcurquant [songgetunit]/$denom
} 

#
# quantise
#
proc q rate {
	trackquant [songgetcurtrack] [songgetcurpos] [songgetcurlen] $rate [songgetcurquant]
} 

#
# cut the given number of measures from the current 
# position on the current track
#
proc cut amount {	 
	trackcut [songgetcurtrack] [songgetcurpos] $amount [songgetcurquant]
}

#
# insert measures in a track, and select them
#
proc ins amount {
	trackinsert [songgetcurtrack] [songgetcurpos] $amount [songgetcurquant]
	songsetcurlen $amount
}

#
# clear a piece of a track
#
proc clr {
	trackblank [songgetcurtrack] [songgetcurpos] [songgetcurlen] [songgetcurquant] {}
}

#
# copy current selection 'where' measures forward
#
proc copy where {
	let track = [songgetcurtrack]
	let from = [songgetcurpos]
	let len = [songgetcurlen]
	trackcopy $track $from $len $track ($where + $from) [songgetcurquant] {}
}

#
# cut a piece of the song
#
proc gcut amount {
	let pos = [songgetcurpos] 
	let quant = [songgetcurquant]
	for i in [tracklist] {
		trackcut $i $pos $amount $quant
	}
}

#
# insert measures in the song
#
proc gins amount {
	let pos = [songgetcurpos] 
	let quant = [songgetcurquant]
	for i in [tracklist] {
		trackinsert $i $pos $amount $quant
	}
	songsetcurlen $amount
}

#
# copy a piece of the song 'where' measures forward
#
proc gcopy where {
	let from = [songgetcurpos]
	let amount = [songgetcurlen] 
	let quant = [songgetcurquant]
	for track in [tracklist] {
		trackcopy $track $from $amount $track ($where + $from) $quant {}
	}
}


#
# mute a track
#
proc mute track {
	tracksetmute $track 1
}

#
# unmute a track
#
proc unmute track {
	tracksetmute $track 0
}

#
# unmute all tracks
#
proc nomute {
	for i in [tracklist] {
		tracksetmute $i 0
	}
}

#
# mute all tracks but current
#
proc solo {
	let curtrack = [songgetcurtrack]
	for i in [tracklist] {
		tracksetmute $i ($i != $curtrack)
	}
}

#
# save the song
#
proc save filename {
	songsave $filename
}

#
# load a song
#
proc load filename {
	songload $filename
}

#
# export a song in a .mid
#
proc export filename {
	songexportsmf $filename
}

#
# import a song from a .mid
#
proc import filename {
	songimportsmf $filename
}

#
# change tempo a current position
#
proc tempo beat_per_measure {
	songsettempo [songgetcurpos] $beat_per_measure
}

#
# insert measures in the meta-track
#
proc timeins amount numerator denominator {
	songtimeins [songgetcurpos] $amount $numerator $denominator
}

#
# remove measures from the meta-track
#
proc timerm amount {
	songtimerm [songgetcurpos] $amount
}

#
# turn on general midi (send sysex)
#
proc gmon devnum {
	sendraw $devnum { 0xF0 0x7E 0x7F 0x09 0x01 0xF7 }
}

#
# configure an instrument for a given general midi patch
#
proc gmp patch {
	let chan = [songgetcurchan]
	chanconfev $chan { pc $chan ($patch - 1) }
}

#
# XV-2020 specific macros
#
# configures a instrument with the given bank/patch or bank rhythm
# bank 1,2,3,4 corresponds to preset A,B,C,D
# patches/rhythmes are counted from 1 to 128
#
proc xvp bank patch {
	let chan = [songgetcurchan]
	chanconfev $chan { ctl $chan 0  87 } 
	chanconfev $chan { ctl $chan 32 (64 + $bank - 1) } 
	chanconfev $chan { pc  $chan ($patch  - 1) }
}
proc xvr bank rhythm { 
	let chan = [songgetcurchan]
	chanconfev $chan { ctl $chan 0  86 } 
	chanconfev $chan { ctl $chan 32 (64 + $bank - 1) } 
	chanconfev $chan { pc  $chan ($rhythm - 1) }
}

#
# generate a sysex message that set parameter on 
# address (a0,a1,a2,a3) to val
#
proc xvparam a0 a1 a2 a3 val {
	return {  							\
		0xf0 0x41 0x7f 0x00 0x10 0x12 $a0 $a1 $a2 $a3 $val	\
		128 - ($a0 + $a1 + $a2 + $a3 + $val) % 128		\
		0xf7 }
}

#
# controllers config
#
proc mod    v { let c = [songgetcurchan]; chanconfev $c {ctl $c 1  $v}; }
proc breath v { let c = [songgetcurchan]; chanconfev $c {ctl $c 2  $v}; }
proc vol    v { let c = [songgetcurchan]; chanconfev $c {ctl $c 7  $v}; }
proc bal    v { let c = [songgetcurchan]; chanconfev $c {ctl $c 8  $v}; }
proc pan    v { let c = [songgetcurchan]; chanconfev $c {ctl $c 10 $v}; }
proc reverb v { let c = [songgetcurchan]; chanconfev $c {ctl $c 91 $v}; }
proc chorus v { let c = [songgetcurchan]; chanconfev $c {ctl $c 93 $v}; }