/
songmaster.cmd
232 lines (211 loc) · 4.81 KB
/
songmaster.cmd
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
@rem Use delayed expansion or else vars evaluated at start of a () block
@setlocal EnableDelayedExpansion
@
@rem set _debug=true
@rem delete "@rem " in previous line to debug
@if [%_debug%]==[] echo off
rem [%1][%2][%3]
goto start
:usage
echo songmaster.cmd - Call Song Master OSC API
echo.
echo play { on off }
echo speed { 20 40 50 60 70 80 90 100 120 }
echo pitch { up down key} { octave 0...n }
echo mute { on off } { 1 - 5 }
echo solo { 1 - 5 off }
echo metronome { on off }
echo loop { on off bar section note track }
echo goto { start end } or {next previous } {bar section note }
echo playlist { 1...n info songs next previous }
set exitcode=1
goto exit
:start
set cosc=%~dp0\x64\Release\cosc
set what=%1
set param1=%2
set param2=%3
if [%what%] == [play] (
if [%param1%] == [on] (
set value=1
) else (
set value=0
)
set cmd=/play
set params=i !value!
) else if [%what%] == [speed] (
if [%param1%] == [] (
set param1=bpm
)
if [!param1!] == [bmp] (
set value=1.0
) else if !param1! LEQ 20 (
set value=0.2
) else if !param1! LEQ 40 (
set value=0.4
) else if !param1! EQU 50 (
set value=0.5
) else if !param1! LEQ 60 (
set value=0.6
) else if !param1! LEQ 70 (
set value=0.7
) else if !param1! LEQ 80 (
set value=0.8
) else if !param1! LEQ 90 (
set value=0.9
) else if !param1! EQU 100 (
set value=1.0
) else if !param1! LEQ 120 (
set value=1.2
) else (
set value=1.0
)
set cmd=/speed
set params=f !value!
) else if [%what%] == [pitch] (
if [%param1%] == [key] (
set sign=+
set semitones=0
) else if [%param1%] == [down] (
set sign=-
) else (
set sign=+
)
if [%param2%] == [octave] (
set semitones=12
) else (
set semitones=!param2!
)
set cmd=/pitch
set params=i !sign!!semitones!
) else if [%what%] == [mute] (
if [%param2%] == [] (
goto usage
) else if !param2! LSS 10 (
set track=%param2%
if [%param1%] == [on] (
set state=1
) else (
set state=0
)
)
set cmd=/stemTrack!track!Mute
set params=i !state!
) else if [%what%] == [solo] (
if [%param1%] == [] (
goto usage
) else if !param1! LSS 10 (
set track=%param1%
set state=1
) else if [%param1%] == [off] (
set track=1
set state=0
)
set cmd=/stemTrack!track!Solo
set params=i !state!
) else if [%what%] == [metronome] (
if [%param1%] == [on] (
set state=1
) else (
set state=0
)
set cmd=/metronomeEnable
set params=i !state!
) else if [%what%] == [loop] (
if [%param1%] == [] (
set param1=on
) else if [%param1%] == [0] (
set param1=bar
) else if [%param1%] == [1] (
set param1=note
) else if [%param1%] == [2] (
set param1=section
)
if [!param1!] == [on] (
set action=Enable
set state=1
) else if [!param1!] == [off] (
set action=Enable
set state=0
) else if [!param1!] == [bar] (
set action=SetToCurrentBar
set state=1
) else if [!param1!] == [section] (
set action=SetToCurrentSection
set state=1
) else if [!param1!] == [note] (
set action=SetToCurrentNote
set state=1
)
set cmd=/loop!action!
set params=i !state!
) else if [%what%] == [goto] (
if [%param1%] == [] (
set param1=start
) else if [%param2%] == [0] (
set param2=bar
) else if [%param2%] == [1] (
set param2=note
) else if [%param2%] == [2] (
set param2=section
) else if [%param2%] == [100] (
if [!param1!] == [next] (
set param1=end
) else (
set param1=start
)
set param2=
)
if [!param1!] == [start] (
set action=BeginningOfTrack
) else if [!param1!] == [end] (
set action=EndOfTrack
) else if [!param1!] == [next] (
set action=Next
) else if [!param1!] == [previous] (
set action=Prev
)
if [!param2!] == [note] (
set action=!action!Note
) else if [!param2!] == [bar] (
set action=!action!Bar
) else if [!param2!] == [section] (
set action=!action!Section
)
set cmd=/goto!action!
set params=i 1
) else if [%what%] == [playlist] (
if [%param1] == [] (
goto usage
) else if [%param1%] == [on] (
set param1=next
)
if !param1! LEQ 100 (
set action=PlayIndex
set /a "index=!param1!-1"
set trackp=i !index!
) else if [!param1!] == [info] (
set action=Info
) else if [!param1!] == [songs] (
set action=Songs
) else if [!param1!] == [next] (
set action=PlayNext
) else if [!param1!] == [previous] (
set action=PlayPrev
)
set cmd=/playlist!action!
set params=!trackp! i 1
) else (
goto usage
)
set host=127.0.0.1
set txport=8000
set rxport=9000
set timeout=500
if NOT [%_debug%] == [] start "" echo [%1][%2][%3] %cosc% !host! !txport! !rxport! !timeout! !cmd! !params!
%cosc% !host! !txport! !rxport! !timeout! !cmd! !params!
set exitcode=0
goto exit
:exit
endlocal
exit /b %exitcode%