Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 5 commits
  • 10 files changed
  • 0 comments
  • 1 contributor
Feb 13, 2012
Werner Almesberger stimuli: remember last MIDI value and reset control to it before star…
…ting

It's a little hackish to do this from stim_redirect, but since this is
what we call before launching a new patch and it has all the information
we need, it really is the best place.
63ea9e9
Werner Almesberger patch editor: generalized double quote protection
This will allow the use of double quote protection also for compiler
errors.
5e6707f
Werner Almesberger patch editor: protect double quotes also in compiler diagnostics 49a1282
Werner Almesberger stimuli: stim_db_free didn't reset the "last" pointer
This allowed only the first compilation of a patch with MIDI devices to work.
d516fe9
Werner Almesberger MIDI documentation (WIP, continuing) 3b739f3
16  src/compiler/doc/Makefile
@@ -3,7 +3,7 @@ fig2pdf = ./figfilt $(1) <$< | \
3 3
 
4 4
 PICEXT = pdf
5 5
 
6  
-PICS = bind stim \
  6
+PICS = arch msg bind stim \
7 7
        button-up button-down \
8 8
        switch-off switch-on \
9 9
        fader-0 fader-40 fader-60 fader-100 \
@@ -12,16 +12,24 @@ PICS = bind stim \
12 12
        dial-0 dial-90 dial-180 dial-360 \
13 13
        dial-405 dial-315
14 14
 
  15
+GEN = nocvars.inc
  16
+
15 17
 .PHONY:			all xpdf clean
16 18
 
17 19
 all:			midi.pdf
18 20
 
19  
-midi.pdf:		midi.tex $(PICS:%=%.$(PICEXT))
  21
+midi.pdf:		midi.tex $(PICS:%=%.$(PICEXT)) $(GEN)
20 22
 			pdflatex midi
21 23
 
22 24
 xpdf:			midi.pdf
23 25
 			xpdf $<
24 26
 
  27
+arch.pdf:		arch.fig
  28
+			fig2dev -L pdf -m 0.9 $< $@ || { rm -rf $@; exit 1; }
  29
+
  30
+msg.pdf:		msg.fig
  31
+			fig2dev -L pdf -m 0.9 $< $@ || { rm -rf $@; exit 1; }
  32
+
25 33
 bind.pdf:		bind.fig
26 34
 			fig2dev -L pdf -m 0.9 $< $@ || { rm -rf $@; exit 1; }
27 35
 
@@ -97,6 +105,10 @@ dial-405.$(PICEXT):	dial.fig
97 105
 dial-315.$(PICEXT):	dial.fig
98 106
 			$(call fig2pdf, 315deg ccw)
99 107
 
  108
+nocvars.inc:		../fnp.ids
  109
+			./mknocvars <$< >$@ || { rm -f $@; exit 1; }
  110
+
100 111
 clean:
101 112
 			rm -f $(PICS:%=%.$(PICEXT))
  113
+			rm -f $(GEN)
102 114
 			rm -f midi.aux midi.log
94  src/compiler/doc/arch.fig
... ...
@@ -0,0 +1,94 @@
  1
+#FIG 3.2  Produced by xfig version 3.2.5b
  2
+Landscape
  3
+Center
  4
+Metric
  5
+A4      
  6
+100.00
  7
+Single
  8
+-2
  9
+1200 2
  10
+0 32 #c1c1c1
  11
+6 3555 6255 4770 7065
  12
+2 1 0 2 32 7 53 -1 -1 0.000 0 0 -1 0 0 2
  13
+	 3600 6480 4725 6480
  14
+2 1 0 2 32 7 53 -1 -1 0.000 0 0 -1 0 0 2
  15
+	 3600 6660 4725 6660
  16
+2 1 0 2 32 7 53 -1 -1 0.000 0 0 -1 0 0 2
  17
+	 3600 6840 4725 6840
  18
+2 2 0 2 32 7 55 -1 -1 0.000 0 0 -1 0 0 5
  19
+	 3600 6300 4725 6300 4725 7020 3600 7020 3600 6300
  20
+-6
  21
+6 3330 3330 4770 4320
  22
+1 1 0 3 0 7 50 -1 -1 0.000 1 0.0000 4050 3825 675 450 4050 3825 4725 4275
  23
+4 1 0 45 -1 18 12 0.0000 4 150 1050 4050 3915 Translation\001
  24
+-6
  25
+6 6480 2205 8370 4995
  26
+2 2 0 2 0 7 55 -1 -1 0.000 0 0 -1 0 0 5
  27
+	 6525 2250 8325 2250 8325 4950 6525 4950 6525 2250
  28
+4 0 0 45 -1 18 12 0.0000 4 195 1560 6750 2925 var = range(aux);\001
  29
+4 0 32 55 -1 18 12 0.0000 4 195 990 6750 3240 per_frame:\001
  30
+4 0 32 55 -1 18 12 0.0000 4 180 960 6975 3555 rot = time;\001
  31
+4 0 32 55 -1 18 12 0.0000 4 135 1110 6975 3870 zoom = var;\001
  32
+4 0 32 55 -1 18 12 0.0000 4 105 840 6750 2610 ...more...\001
  33
+4 0 32 55 -1 18 12 0.0000 4 105 840 6975 4185 ...more...\001
  34
+-6
  35
+6 1305 3825 1665 4185
  36
+1 3 0 2 0 7 50 -1 -1 0.000 1 0.0000 1485 4005 127 127 1485 4005 1395 3915
  37
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
  38
+	 1485 4005 1395 3915
  39
+-6
  40
+6 1485 3285 1665 3600
  41
+5 1 0 2 0 7 50 -1 -1 0.000 0 0 0 0 1575.000 3375.000 1530 3375 1575 3330 1620 3375
  42
+5 1 0 2 0 7 50 -1 -1 0.000 0 1 0 0 1575.000 3510.000 1530 3510 1575 3555 1620 3510
  43
+1 3 0 2 0 7 47 -1 15 0.000 1 0.0000 1575 3375 45 45 1575 3375 1620 3375
  44
+2 1 0 2 0 7 49 -1 -1 0.000 0 0 -1 0 0 2
  45
+	 1530 3375 1530 3510
  46
+2 1 0 2 0 7 49 -1 -1 0.000 0 0 -1 0 0 2
  47
+	 1620 3375 1620 3510
  48
+-6
  49
+1 3 0 2 0 7 50 -1 -1 0.000 1 0.0000 1080 3420 90 90 1080 3420 1170 3420
  50
+1 3 0 2 0 7 50 -1 -1 0.000 1 0.0000 1350 3420 90 90 1350 3420 1440 3420
  51
+2 1 0 2 0 7 53 -1 -1 0.000 0 0 -1 0 0 2
  52
+	 3600 5355 4725 5355
  53
+2 1 0 2 0 7 53 -1 -1 0.000 0 0 -1 0 0 2
  54
+	 3600 5535 4725 5535
  55
+2 1 0 2 0 7 53 -1 -1 0.000 0 0 -1 0 0 2
  56
+	 3600 5715 4725 5715
  57
+2 1 0 2 0 7 53 -1 -1 0.000 0 0 -1 0 0 2
  58
+	 3600 5895 4725 5895
  59
+2 2 0 2 0 7 55 -1 -1 0.000 0 0 -1 0 0 5
  60
+	 3600 5175 4725 5175 4725 6075 3600 6075 3600 5175
  61
+2 2 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
  62
+	 2925 4950 4950 4950 4950 7200 2925 7200 2925 4950
  63
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
  64
+	1 1 2.00 60.00 60.00
  65
+	 4050 4905 4050 4320
  66
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
  67
+	1 1 2.00 60.00 60.00
  68
+	 1305 4545 1305 5625 2880 5625
  69
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
  70
+	1 1 2.00 60.00 60.00
  71
+	 1890 3825 3330 3825
  72
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 1 0 3
  73
+	1 1 2.00 60.00 60.00
  74
+	 4770 3825 6885 3825 6885 2970
  75
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
  76
+	1 1 2.00 60.00 60.00
  77
+	 6705 2880 4050 2880 4050 3330
  78
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
  79
+	 1080 4320 1080 3645
  80
+2 1 0 4 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
  81
+	 990 4095 1170 4095
  82
+2 2 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
  83
+	 810 3150 1800 3150 1800 4500 810 4500 810 3150
  84
+4 1 0 45 -1 18 12 0.0000 4 150 525 12330 6570 Patch\001
  85
+4 1 0 45 -1 18 12 0.0000 4 150 435 3285 5355 dev1\001
  86
+4 1 0 45 -1 18 12 0.0000 4 150 435 3285 6480 dev2\001
  87
+4 0 0 45 -1 18 12 0.0000 4 150 1380 4185 4725 Characteristics\001
  88
+4 1 0 45 -1 18 12 0.0000 4 150 630 2610 3735 Events\001
  89
+4 1 0 45 -1 18 12 0.0000 4 150 1500 3960 7470 Device database\001
  90
+4 1 0 45 -1 18 12 0.0000 4 150 825 4680 2790 Function\001
  91
+4 1 0 45 -1 18 12 0.0000 4 195 690 2115 5535 Identify\001
  92
+4 1 0 45 -1 18 12 0.0000 4 195 1605 5625 3735 Variable changes\001
  93
+4 1 0 45 -1 18 12 0.0000 4 150 525 7470 5220 Patch\001
  94
+4 1 0 45 -1 18 12 0.0000 4 150 1080 1305 3015 MIDI device\001
8  src/compiler/doc/bind.fig
@@ -134,9 +134,7 @@ Single
134 134
 2 2 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
135 135
 	 7425 7650 10125 7650 10125 8100 7425 8100 7425 7650
136 136
 4 1 0 50 -1 18 12 0.0000 4 150 690 5400 6255 MIDICC\001
137  
-4 1 0 50 -1 18 12 0.0000 4 105 330 4815 6255 aux\001
138  
-4 1 0 50 -1 18 12 0.0000 4 135 105 5850 6255 1\001
139  
-4 1 0 50 -1 18 12 0.0000 4 135 210 6300 6255 16\001
  137
+4 1 0 50 -1 18 12 0.0000 4 135 315 6300 6255 103\001
140 138
 4 1 0 50 -1 18 12 0.0000 4 195 300 6750 6255 pot\001
141 139
 4 1 0 45 -1 18 12 0.0000 4 150 435 4185 6030 dev1\001
142 140
 4 1 0 50 -1 18 12 0.0000 4 150 1050 10350 3555 Translators\001
@@ -151,9 +149,11 @@ Single
151 149
 4 1 0 50 -1 18 12 0.0000 4 150 330 8955 8370 Ctrl\001
152 150
 4 1 0 50 -1 18 12 0.0000 4 150 435 9450 8370 Proc\001
153 151
 4 1 0 50 -1 18 12 0.0000 4 150 315 9900 8370 Var\001
154  
-4 1 0 50 -1 18 12 0.0000 4 135 210 8955 7965 16\001
  152
+4 1 0 50 -1 18 12 0.0000 4 135 315 8955 7965 103\001
155 153
 4 1 0 50 -1 18 12 0.0000 4 150 480 8415 8370 Chan\001
156 154
 4 1 0 50 -1 18 12 0.0000 4 135 105 8415 7965 1\001
157 155
 4 1 0 50 -1 18 12 0.0000 4 195 450 7785 8370 Type\001
158 156
 4 1 0 50 -1 18 12 0.0000 4 150 690 7785 7965 MIDICC\001
159 157
 4 1 0 50 -1 18 12 0.0000 4 195 1365 8730 8775 Stimulus entry\001
  158
+4 1 0 50 -1 18 12 0.0000 4 135 105 5940 6255 1\001
  159
+4 1 0 50 -1 18 12 0.0000 4 105 330 4770 6255 aux\001
134  src/compiler/doc/midi.tex
@@ -19,14 +19,18 @@
19 19
 
20 20
 \maketitle
21 21
 
  22
+\begin{abstract}
  23
+This document describes how MIDI 
  24
+\end{abstract}
  25
+
  26
+%\setcounter{tocdepth}{1}
  27
+\tableofcontents
22 28
 
23 29
 % -----------------------------------------------------------------------------
24 30
 
25 31
 
26 32
 \section{Introduction}
27 33
 
28  
-This document describes the architecture of the MIDI control @@@
29  
-
30 34
 Note that this work is still in progress. For example,
31 35
 \begin{itemize}
32 36
   \item the MIDI device specifications should not have to be part of
@@ -54,7 +58,7 @@ \section{Quick start}
54 58
 	but2 = button(17);
55 59
 }
56 60
 
57  
-sensitivity = linear(main);
  61
+sensitivity = range(main);
58 62
 
59 63
 per_frame:
60 64
 	wave_scale = sensitivity*10;
@@ -81,40 +85,97 @@ \section{Quick start}
81 85
 
82 86
 \section{Architecture}
83 87
 
  88
+When a MIDI device is1
  89
+\begin{figure}[!tb]
  90
+\begin{center}
  91
+\includegraphics{arch.pdf}
  92
+\end{center}
  93
+\caption{Input event processing in Flickernoise.}
  94
+\label{arch}
  95
+\end{figure}
  96
+
84 97
 
85 98
 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
86 99
 
87 100
 
88  
-\subsection{MIDI control message}
  101
+\subsection{MIDI control messages}
  102
+
  103
+A MIDI device sends a message each time one of its elements is actuated.
  104
+There are various types of elements, keys, pitch wheels, controls, etc.
  105
+Controls can be all sorts of things, including faders, potentiometers,
  106
+and push buttons.
  107
+
  108
+For now, we only consider controls. When a control is actuated, the
  109
+MIDI device generates a MIDI Control Change messages, as shown in
  110
+figure \ref{msg}.
  111
+
  112
+\begin{figure}[!tb]
  113
+\begin{center}
  114
+\includegraphics{msg.pdf}
  115
+\end{center}
  116
+\caption{Anatomy of a MIDI Control Change message.}
  117
+\label{msg}
  118
+\end{figure}
  119
+
  120
+Channel numbers are encoded as values from 0 to 15 in the actual
  121
+MIDI message but are commonly presented as 1 to 16 to the user.
  122
+Also Flickernoise follows this convention.
89 123
 
90  
-- MIDI: 0-127
  124
+Most MIDI devices use a single channel. The number of this channel
  125
+can sometimes be set by the user. The controller numbers are typically
  126
+fixed.
  127
+
  128
+Flickernoise uses the message type, the channel number, and the controller
  129
+number to determine where to send the value. 
91 130
 
92 131
 
93 132
 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
94 133
 
95 134
 
96  
-\subsection{...}
  135
+\subsection{@@@}
  136
+
97 137
 
  138
+@@@
98 139
 
99 140
 % -----------------------------------------------------------------------------
100 141
 
101  
-\section{Configuration process}
  142
+
  143
+\section{Using controls in patches}
  144
+
  145
+@@@
102 146
 
103 147
 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104 148
 
105 149
 
106 150
 \subsection{Device database}
107 151
 
  152
+The device database tells Flickernoise how to identify MIDI
  153
+devices and how to 
108 154
 Device specifications are added to the device database with 
109 155
 - global section
110 156
 
  157
+\begin{expose}
  158
+{\tt midi} {\em identification} \verb"{" {\em element $\ldots$} \verb"}"
  159
+\end{expose}
  160
+
  161
+Each element has the following syntax:
  162
+
  163
+\begin{expose}
  164
+{\tt {\em name} =
  165
+  {\em device\_type}($\left[\hbox{\em channel}\verb","\right]$
  166
+  {\em control\_number});}
  167
+\end{expose}
  168
+
  169
+{\em channel} is the MIDI channel number, from 1 to 16. If the channel
  170
+is omitted, the element will match any channel.
  171
+
111 172
 \begin{listing}{1}
112 173
 midi "dev1" {
113 174
 	main = fader(1, 102);
114 175
 	aux = pot(1, 103);
115 176
 	but1 = button(1, 16);
116 177
 	but2 = button(1, 17);
117  
-	tog = switch(1, 24);
  178
+	sw = switch(1, 24);
118 179
 }
119 180
 \end{listing}
120 181
 
@@ -137,8 +198,9 @@ \subsection{Binding}
137 198
 
138 199
 {\em control\_variable} can be a pre-defined per-frame or per-vertex
139 200
 variable or it can be a user-defined variable. Variables that are
140  
-updated by Flickernose itself, e.g., {\tt time} or {\tt bass}, cannot
141  
-be used as control variables.
  201
+updated by Flickernoise itself cannot be used as control variables.
  202
+These variables are
  203
+\input nocvars.inc
142 204
 
143 205
 {\em function} describes how the patch expects the control to behave.
144 206
 Flickernoise then tries to adapt the behaviour of the actual device
@@ -156,11 +218,10 @@ \subsection{Binding}
156 218
   \item[\tt button]
157 219
     The control variable receives the value 1 when the button is
158 220
     pressed and returns to zero when it is released. When applied to
159  
-    elements that send values between 0 and 1, the value is rounded
160  
-    and the control acts like a {\tt switch}.
  221
+    elements that send values between 0 and 1, the value is rounded.
161 222
   \item[\tt switch]
162  
-    The value of the control variable changes between 0 and 1 each
163  
-    time the element -- typically a button -- is actuated. 
  223
+    The control variable can be set to 0 or 1 and retains the value
  224
+    until the element is actuated again.
164 225
 \end{description}
165 226
 
166 227
 {\em element\_name} is the name of the control element, as in the
@@ -168,7 +229,7 @@ \subsection{Binding}
168 229
 
169 230
 \begin{figure}[!tb]
170 231
 \begin{center}
171  
-\includegraphics{bind}
  232
+\includegraphics{bind.pdf}
172 233
 \end{center}
173 234
 \caption{When binding a control variable, information from the device
174 235
   database, a translation map, and the table of patch variables is
@@ -184,7 +245,7 @@ \subsection{Event processing}
184 245
 
185 246
 \begin{figure}[!tb]
186 247
 \begin{center}
187  
-\includegraphics{stim}
  248
+\includegraphics{stim.pdf}
188 249
 \end{center}
189 250
 \caption{When a MIDI control message is received, Flickernoise looks
190 251
   for a matching stimulus and processes the value accordingly.}
@@ -211,11 +272,39 @@ \subsection{Event processing}
211 272
 
212 273
 \subsection{Writing to control variables}
213 274
 
214  
-- pfv
215  
-- pvv
216  
-- continuity
  275
+A patch can overwrite the values control variables. In the case of
  276
+per-frame variables, they retain their modified content across
  277
+frames until a new event arrives. The new event will always overwrite
  278
+the previous value of the variable without regard for any changes that
  279
+may have been made.
  280
+
  281
+Changes to per-vertex variables are lost at the end of the program.
  282
+
  283
+It is sometimes desirable to make a control change a variable relative
  284
+to a value set by the patch. The following example illustrates how
  285
+this can be accomplished:
  286
+
  287
+\begin{listing}{1}
  288
+cvar = range(foo);
  289
+
  290
+per_frame:
  291
+	var = var+cvar-last;
  292
+	last = cvar;
  293
+	/* ... use "var" ... */
  294
+	var = condition ? new_value : var;
  295
+\end{listing}
  296
+
  297
+Instead of writing to the control variable {\tt cvar} directly, we
  298
+propagate any relative changes of {\tt cvar} to {\tt var} in lines
  299
+4 and 5, and only modify {\tt var} in line 7.
  300
+
  301
+Note that {\tt var} may assume values outside the range $0\ldots 1$.
  302
+If this is not desirable, it can be clipped after line 4 with
  303
+
  304
+\begin{listing}{1}
  305
+	var = max(min(var, 1), 0);
  306
+\end{listing}
217 307
 
218  
-exercised to avoid any of the per-defined variables that are updated
219 308
 
220 309
 % -----------------------------------------------------------------------------
221 310
 
@@ -429,12 +518,11 @@ \subsection{Switches}
429 518
 var = switch(name);
430 519
 \end{listing}
431 520
 
432  
-In the example below, we indicate whether the control is activated
433  
-by a lamp next to the button:
  521
+Switches behave the same for all functions:
434 522
 
435 523
 \begin{expose}
436 524
 \begin{tabular}{lcccl}
437  
-  \raisebox{6mm}{User input} &
  525
+  \raisebox{4mm}{User input} &
438 526
   \includegraphics{switch-off.pdf} &
439 527
   \includegraphics{switch-on.pdf} &
440 528
   \includegraphics{switch-off.pdf} \\
18  src/compiler/doc/mknocvars
... ...
@@ -0,0 +1,18 @@
  1
+#!/bin/sh -e
  2
+#
  3
+# mknocvars - Generate the list of variables forbidden as control variables
  4
+#
  5
+# Copyright 2012 by Werner Almesberger
  6
+#
  7
+# This program is free software: you can redistribute it and/or modify
  8
+# it under the terms of the GNU General Public License as published by
  9
+# the Free Software Foundation, version 3 of the License.
  10
+#
  11
+
  12
+sed 's/#.*//;/^ *$/d' $1 | LANG=C sort | {
  13
+	while read n; do
  14
+		echo "$n" | grep SF_LIVE >/dev/null || continue
  15
+		set - $n
  16
+		echo $1 | sed 's/[0-9]$/{\\em n}/'
  17
+	done
  18
+} | uniq | sed 's/_/\\_/g;s/.*/{\\tt &},/' | sed '${s/,$/./;s/^/and /;}'
39  src/compiler/doc/msg.fig
... ...
@@ -0,0 +1,39 @@
  1
+#FIG 3.2  Produced by xfig version 3.2.5b
  2
+Landscape
  3
+Center
  4
+Metric
  5
+A4      
  6
+100.00
  7
+Single
  8
+-2
  9
+1200 2
  10
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
  11
+	 3375 1845 3375 2205
  12
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
  13
+	 4275 1845 4275 2205
  14
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
  15
+	 5175 1845 5175 2205
  16
+2 2 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
  17
+	 2475 1800 6075 1800 6075 2250 2475 2250 2475 1800
  18
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
  19
+	 2925 1395 2925 1755
  20
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
  21
+	 3825 1575 3825 1755
  22
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
  23
+	 4725 1350 4725 1755
  24
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
  25
+	 5625 1575 5625 1755
  26
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
  27
+	 2925 2340 2925 2610
  28
+4 1 0 50 -1 18 15 0.0000 4 180 360 2925 2115 CC\001
  29
+4 1 0 50 -1 18 15 0.0000 4 180 270 5625 2115 28\001
  30
+4 1 0 50 -1 18 15 0.0000 4 180 405 4725 2115 103\001
  31
+4 1 0 50 -1 18 15 0.0000 4 180 135 3825 2115 0\001
  32
+4 1 0 50 -1 18 12 0.0000 4 150 765 3825 1530 Channel\001
  33
+4 1 0 50 -1 18 12 0.0000 4 150 525 5625 1530 Value\001
  34
+4 1 0 50 -1 18 12 0.0000 4 135 480 4725 2520 0-127\001
  35
+4 1 0 50 -1 18 12 0.0000 4 135 375 3825 2520 0-15\001
  36
+4 1 0 50 -1 18 12 0.0000 4 135 480 5625 2520 0-127\001
  37
+4 1 0 50 -1 18 12 0.0000 4 195 1455 3240 2790 Control Change\001
  38
+4 1 0 50 -1 18 12 0.0000 4 150 930 4725 1305 Controller\001
  39
+4 1 0 50 -1 18 12 0.0000 4 195 1260 2925 1305 Message type\001
4  src/compiler/doc/stim.fig
@@ -95,14 +95,14 @@ Single
95 95
 4 1 0 50 -1 18 12 0.0000 4 150 480 2520 1440 Chan\001
96 96
 4 1 0 50 -1 18 12 0.0000 4 135 105 2520 1890 1\001
97 97
 4 1 0 50 -1 18 12 0.0000 4 150 330 3015 1440 Ctrl\001
98  
-4 1 0 50 -1 18 12 0.0000 4 135 210 3060 1890 16\001
  98
+4 1 0 50 -1 18 12 0.0000 4 135 315 3060 1890 103\001
99 99
 4 1 0 50 -1 18 12 0.0000 4 135 210 3555 1890 28\001
100 100
 4 1 0 50 -1 18 12 0.0000 4 150 525 3555 1440 Value\001
101 101
 4 1 0 50 -1 18 12 0.0000 4 150 420 1125 1755 MIDI\001
102 102
 4 1 0 50 -1 18 12 0.0000 4 195 450 3645 3780 Type\001
103 103
 4 1 0 50 -1 18 12 0.0000 4 150 480 4185 3780 Chan\001
104 104
 4 1 0 50 -1 18 12 0.0000 4 150 330 4680 3780 Ctrl\001
105  
-4 1 0 50 -1 18 12 0.0000 4 135 210 4680 3555 16\001
  105
+4 1 0 50 -1 18 12 0.0000 4 135 315 4680 3555 103\001
106 106
 4 1 0 45 -1 18 12 0.0000 4 150 435 5130 3780 Proc\001
107 107
 4 1 0 45 -1 18 12 0.0000 4 150 315 5535 3780 Var\001
108 108
 4 1 0 50 -1 18 12 0.0000 4 135 480 7740 2340 0.220\001
18  src/compiler/doc/switch.fig
@@ -7,17 +7,17 @@ A4
7 7
 Single
8 8
 -2
9 9
 1200 2
10  
-5 1 0 4 0 7 50 -1 -1 0.000 0 0 0 0 4590.000 4500.000 4275 4500 4590 4185 4905 4500
11  
-5 1 0 4 0 7 50 -1 -1 0.000 0 1 0 0 4590.000 5400.000 4275 5400 4590 5715 4905 5400
  10
+5 1 0 4 0 7 50 -1 -1 0.000 0 0 0 0 4455.000 4500.000 4050 4500 4455 4095 4860 4500
  11
+5 1 0 4 0 7 50 -1 -1 0.000 0 1 0 0 4455.000 5400.000 4050 5400 4455 5805 4860 5400
12 12
 # on
13  
-1 3 0 4 0 7 45 -1 49 0.000 1 0.0000 4590 4500 315 315 4590 4500 4905 4500
  13
+1 3 0 4 0 7 45 -1 49 0.000 1 0.0000 4455 4500 405 405 4455 4500 4860 4500
14 14
 # off
15  
-1 3 0 4 0 7 45 -1 49 0.000 1 0.0000 4590 5400 315 315 4590 5400 4905 5400
  15
+1 3 0 4 0 7 45 -1 49 0.000 1 0.0000 4455 5400 405 405 4455 5400 4860 5400
16 16
 2 1 0 4 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
17  
-	 4275 4500 4275 5400
  17
+	 4860 4500 4860 5400
18 18
 2 1 0 4 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
19  
-	 4905 4500 4905 5400
  19
+	 4050 4500 4050 5400
20 20
 2 2 0 1 7 7 50 -1 -1 0.000 0 0 -1 0 0 5
21  
-	 4050 3915 6210 3915 6210 5985 4050 5985 4050 3915
22  
-4 0 0 50 -1 18 28 0.0000 4 345 930 5175 5670 OFF\001
23  
-4 0 0 50 -1 18 28 0.0000 4 345 690 5175 4545 ON\001
  21
+	 3825 3870 6345 3870 6345 6075 3825 6075 3825 3870
  22
+4 0 0 50 -1 18 32 0.0000 4 390 810 5175 4590 ON\001
  23
+4 0 0 50 -1 18 32 0.0000 4 390 1080 5175 5715 OFF\001
49  src/gui/patcheditor.c
@@ -40,6 +40,31 @@ static struct filedialog *filesave_dlg;
40 40
 static int modified;
41 41
 static char current_filename[384];
42 42
 
  43
+static char *protect_string(const char *s)
  44
+{
  45
+	int n = 0;
  46
+	const char *p;
  47
+	char *buf, *d;
  48
+
  49
+	for(p = s; *p; p++)
  50
+		if(*p == '"')
  51
+			n++;
  52
+
  53
+	buf = malloc(p-s+n+1);
  54
+	if(!buf)
  55
+		return NULL;
  56
+
  57
+	d = buf;
  58
+	for(p = s; *p; p++) {
  59
+		if(*p == '"')
  60
+			*d++ = '\\';
  61
+		*d++ = *p;
  62
+	}
  63
+	*d = 0;
  64
+
  65
+	return buf;
  66
+}
  67
+
43 68
 static void update_wintitle(void)
44 69
 {
45 70
 	const char *short_filename;
@@ -76,8 +101,8 @@ static void openok_callback(void *arg)
76 101
 {
77 102
 	char buf[MAX_PATCH_SIZE+1];
78 103
 	FILE *fd;
79  
-	int r, n = 0;
80  
-	char *p, *d;
  104
+	int r;
  105
+	char *s;
81 106
 
82 107
 	get_filedialog_selection(fileopen_dlg,
83 108
 	    current_filename, sizeof(current_filename));
@@ -99,25 +124,15 @@ static void openok_callback(void *arg)
99 124
 	}
100 125
 	buf[r] = 0;
101 126
 
102  
-	for(p = buf; *p; p++)
103  
-		if(*p == '"')
104  
-			n++;
105  
-	if(r+n > MAX_PATCH_SIZE) {
  127
+	s = protect_string(buf);
  128
+	if(!s) {
106 129
 		mtk_cmd(appid,
107 130
 		    "status.set(-text \"No room to expand quotes\")");
108 131
 		return;
109 132
 	}
  133
+	mtk_cmdf(appid, "ed.set(-text \"%s\")", s);
  134
+	free(s);
110 135
 
111  
-	d = p+n;
112  
-	do {
113  
-		*d = *p;
114  
-		if(*p == '"')
115  
-			*--d = '\\';
116  
-		p--;
117  
-	}
118  
-	while(d-- != buf);
119  
-
120  
-	mtk_cmdf(appid, "ed.set(-text \"%s\")", buf);
121 136
 	mtk_cmd(appid, "edf.expose(0, 0)");
122 137
 }
123 138
 
@@ -174,7 +189,9 @@ static void saveasok_callback(void *arg)
174 189
 
175 190
 static void rmc(const char *m)
176 191
 {
  192
+	m = protect_string(m);
177 193
 	mtk_cmdf(appid, "status.set(-text \"%s\")", m);
  194
+	free((void *) m);
178 195
 }
179 196
 
180 197
 static void run_callback(mtk_event *e, void *arg)
22  src/renderer/stimuli.c
@@ -9,12 +9,16 @@
9 9
  */
10 10
 
11 11
 #include <stddef.h>
  12
+#include <stdint.h>
12 13
 #include <stdlib.h>
13 14
 #include <string.h>
14 15
 
15 16
 #include "stimuli.h"
16 17
 
17 18
 
  19
+static uint8_t midi_last[MIDI_CHANS][MIDI_CTRLS];
  20
+
  21
+
18 22
 /* ----- Low-level register update  ---------------------------------------- */
19 23
 
20 24
 
@@ -99,6 +103,8 @@ void stim_midi_ctrl(struct stimuli *s, int chan, int ctrl, int value)
99 103
 {
100 104
 	struct s_midi_ctrl *ct;
101 105
 
  106
+	midi_last[chan][ctrl] = value;
  107
+
102 108
 	if(!s)
103 109
 		return;
104 110
 
@@ -185,6 +191,20 @@ void stim_put(struct stimuli *s)
185 191
 	free(s);
186 192
 }
187 193
 
  194
+static void reset_control(struct s_midi_ctrl *ct, int chan, int ctrl)
  195
+{
  196
+	void (*proc)(struct s_midi_ctrl *sct, int value);
  197
+
  198
+	proc = ct->proc;
  199
+	if(!proc)
  200
+		return;
  201
+	if(proc == midi_proc_diff_cyclic || proc == midi_proc_diff_unbounded ||
  202
+	    proc == midi_proc_diff_linear)
  203
+		proc(ct, 0);
  204
+	else
  205
+		proc(ct, midi_last[chan][ctrl]);
  206
+}
  207
+
188 208
 void stim_redirect(struct stimuli *s, void *new)
189 209
 {
190 210
 	int i, j;
@@ -204,6 +224,7 @@ void stim_redirect(struct stimuli *s, void *new)
204 224
 				ct->regs.pfv = (void *) ct->regs.pfv+d;
205 225
 			if(ct->regs.pvv)
206 226
 				ct->regs.pvv = (void *) ct->regs.pvv+d;
  227
+			reset_control(ct, i, j);
207 228
 		}
208 229
 	}
209 230
 	s->target = new;
@@ -271,6 +292,7 @@ void stim_db_free(void)
271 292
 		free(db);
272 293
 		db = next;
273 294
 	}
  295
+	last = &db;
274 296
 }
275 297
 
276 298
 

No commit comments for this range

Something went wrong with that request. Please try again.