Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: m-labs/flickernoise
base: 3c77035
...
head fork: m-labs/flickernoise
compare: 3b739f3
Checking mergeability… Don't worry, you can still create the pull request.
  • 5 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
Commits on Feb 13, 2012
@wpwrak wpwrak 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
@wpwrak wpwrak patch editor: generalized double quote protection
This will allow the use of double quote protection also for compiler
errors.
5e6707f
@wpwrak wpwrak patch editor: protect double quotes also in compiler diagnostics 49a1282
@wpwrak wpwrak 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
@wpwrak wpwrak MIDI documentation (WIP, continuing) 3b739f3
View
16 src/compiler/doc/Makefile
@@ -3,7 +3,7 @@ fig2pdf = ./figfilt $(1) <$< | \
PICEXT = pdf
-PICS = bind stim \
+PICS = arch msg bind stim \
button-up button-down \
switch-off switch-on \
fader-0 fader-40 fader-60 fader-100 \
@@ -12,16 +12,24 @@ PICS = bind stim \
dial-0 dial-90 dial-180 dial-360 \
dial-405 dial-315
+GEN = nocvars.inc
+
.PHONY: all xpdf clean
all: midi.pdf
-midi.pdf: midi.tex $(PICS:%=%.$(PICEXT))
+midi.pdf: midi.tex $(PICS:%=%.$(PICEXT)) $(GEN)
pdflatex midi
xpdf: midi.pdf
xpdf $<
+arch.pdf: arch.fig
+ fig2dev -L pdf -m 0.9 $< $@ || { rm -rf $@; exit 1; }
+
+msg.pdf: msg.fig
+ fig2dev -L pdf -m 0.9 $< $@ || { rm -rf $@; exit 1; }
+
bind.pdf: bind.fig
fig2dev -L pdf -m 0.9 $< $@ || { rm -rf $@; exit 1; }
@@ -97,6 +105,10 @@ dial-405.$(PICEXT): dial.fig
dial-315.$(PICEXT): dial.fig
$(call fig2pdf, 315deg ccw)
+nocvars.inc: ../fnp.ids
+ ./mknocvars <$< >$@ || { rm -f $@; exit 1; }
+
clean:
rm -f $(PICS:%=%.$(PICEXT))
+ rm -f $(GEN)
rm -f midi.aux midi.log
View
94 src/compiler/doc/arch.fig
@@ -0,0 +1,94 @@
+#FIG 3.2 Produced by xfig version 3.2.5b
+Landscape
+Center
+Metric
+A4
+100.00
+Single
+-2
+1200 2
+0 32 #c1c1c1
+6 3555 6255 4770 7065
+2 1 0 2 32 7 53 -1 -1 0.000 0 0 -1 0 0 2
+ 3600 6480 4725 6480
+2 1 0 2 32 7 53 -1 -1 0.000 0 0 -1 0 0 2
+ 3600 6660 4725 6660
+2 1 0 2 32 7 53 -1 -1 0.000 0 0 -1 0 0 2
+ 3600 6840 4725 6840
+2 2 0 2 32 7 55 -1 -1 0.000 0 0 -1 0 0 5
+ 3600 6300 4725 6300 4725 7020 3600 7020 3600 6300
+-6
+6 3330 3330 4770 4320
+1 1 0 3 0 7 50 -1 -1 0.000 1 0.0000 4050 3825 675 450 4050 3825 4725 4275
+4 1 0 45 -1 18 12 0.0000 4 150 1050 4050 3915 Translation\001
+-6
+6 6480 2205 8370 4995
+2 2 0 2 0 7 55 -1 -1 0.000 0 0 -1 0 0 5
+ 6525 2250 8325 2250 8325 4950 6525 4950 6525 2250
+4 0 0 45 -1 18 12 0.0000 4 195 1560 6750 2925 var = range(aux);\001
+4 0 32 55 -1 18 12 0.0000 4 195 990 6750 3240 per_frame:\001
+4 0 32 55 -1 18 12 0.0000 4 180 960 6975 3555 rot = time;\001
+4 0 32 55 -1 18 12 0.0000 4 135 1110 6975 3870 zoom = var;\001
+4 0 32 55 -1 18 12 0.0000 4 105 840 6750 2610 ...more...\001
+4 0 32 55 -1 18 12 0.0000 4 105 840 6975 4185 ...more...\001
+-6
+6 1305 3825 1665 4185
+1 3 0 2 0 7 50 -1 -1 0.000 1 0.0000 1485 4005 127 127 1485 4005 1395 3915
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 1485 4005 1395 3915
+-6
+6 1485 3285 1665 3600
+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
+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
+1 3 0 2 0 7 47 -1 15 0.000 1 0.0000 1575 3375 45 45 1575 3375 1620 3375
+2 1 0 2 0 7 49 -1 -1 0.000 0 0 -1 0 0 2
+ 1530 3375 1530 3510
+2 1 0 2 0 7 49 -1 -1 0.000 0 0 -1 0 0 2
+ 1620 3375 1620 3510
+-6
+1 3 0 2 0 7 50 -1 -1 0.000 1 0.0000 1080 3420 90 90 1080 3420 1170 3420
+1 3 0 2 0 7 50 -1 -1 0.000 1 0.0000 1350 3420 90 90 1350 3420 1440 3420
+2 1 0 2 0 7 53 -1 -1 0.000 0 0 -1 0 0 2
+ 3600 5355 4725 5355
+2 1 0 2 0 7 53 -1 -1 0.000 0 0 -1 0 0 2
+ 3600 5535 4725 5535
+2 1 0 2 0 7 53 -1 -1 0.000 0 0 -1 0 0 2
+ 3600 5715 4725 5715
+2 1 0 2 0 7 53 -1 -1 0.000 0 0 -1 0 0 2
+ 3600 5895 4725 5895
+2 2 0 2 0 7 55 -1 -1 0.000 0 0 -1 0 0 5
+ 3600 5175 4725 5175 4725 6075 3600 6075 3600 5175
+2 2 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 2925 4950 4950 4950 4950 7200 2925 7200 2925 4950
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+ 1 1 2.00 60.00 60.00
+ 4050 4905 4050 4320
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
+ 1 1 2.00 60.00 60.00
+ 1305 4545 1305 5625 2880 5625
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
+ 1 1 2.00 60.00 60.00
+ 1890 3825 3330 3825
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 1 0 3
+ 1 1 2.00 60.00 60.00
+ 4770 3825 6885 3825 6885 2970
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
+ 1 1 2.00 60.00 60.00
+ 6705 2880 4050 2880 4050 3330
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 1080 4320 1080 3645
+2 1 0 4 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 990 4095 1170 4095
+2 2 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 810 3150 1800 3150 1800 4500 810 4500 810 3150
+4 1 0 45 -1 18 12 0.0000 4 150 525 12330 6570 Patch\001
+4 1 0 45 -1 18 12 0.0000 4 150 435 3285 5355 dev1\001
+4 1 0 45 -1 18 12 0.0000 4 150 435 3285 6480 dev2\001
+4 0 0 45 -1 18 12 0.0000 4 150 1380 4185 4725 Characteristics\001
+4 1 0 45 -1 18 12 0.0000 4 150 630 2610 3735 Events\001
+4 1 0 45 -1 18 12 0.0000 4 150 1500 3960 7470 Device database\001
+4 1 0 45 -1 18 12 0.0000 4 150 825 4680 2790 Function\001
+4 1 0 45 -1 18 12 0.0000 4 195 690 2115 5535 Identify\001
+4 1 0 45 -1 18 12 0.0000 4 195 1605 5625 3735 Variable changes\001
+4 1 0 45 -1 18 12 0.0000 4 150 525 7470 5220 Patch\001
+4 1 0 45 -1 18 12 0.0000 4 150 1080 1305 3015 MIDI device\001
View
8 src/compiler/doc/bind.fig
@@ -134,9 +134,7 @@ Single
2 2 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
7425 7650 10125 7650 10125 8100 7425 8100 7425 7650
4 1 0 50 -1 18 12 0.0000 4 150 690 5400 6255 MIDICC\001
-4 1 0 50 -1 18 12 0.0000 4 105 330 4815 6255 aux\001
-4 1 0 50 -1 18 12 0.0000 4 135 105 5850 6255 1\001
-4 1 0 50 -1 18 12 0.0000 4 135 210 6300 6255 16\001
+4 1 0 50 -1 18 12 0.0000 4 135 315 6300 6255 103\001
4 1 0 50 -1 18 12 0.0000 4 195 300 6750 6255 pot\001
4 1 0 45 -1 18 12 0.0000 4 150 435 4185 6030 dev1\001
4 1 0 50 -1 18 12 0.0000 4 150 1050 10350 3555 Translators\001
@@ -151,9 +149,11 @@ Single
4 1 0 50 -1 18 12 0.0000 4 150 330 8955 8370 Ctrl\001
4 1 0 50 -1 18 12 0.0000 4 150 435 9450 8370 Proc\001
4 1 0 50 -1 18 12 0.0000 4 150 315 9900 8370 Var\001
-4 1 0 50 -1 18 12 0.0000 4 135 210 8955 7965 16\001
+4 1 0 50 -1 18 12 0.0000 4 135 315 8955 7965 103\001
4 1 0 50 -1 18 12 0.0000 4 150 480 8415 8370 Chan\001
4 1 0 50 -1 18 12 0.0000 4 135 105 8415 7965 1\001
4 1 0 50 -1 18 12 0.0000 4 195 450 7785 8370 Type\001
4 1 0 50 -1 18 12 0.0000 4 150 690 7785 7965 MIDICC\001
4 1 0 50 -1 18 12 0.0000 4 195 1365 8730 8775 Stimulus entry\001
+4 1 0 50 -1 18 12 0.0000 4 135 105 5940 6255 1\001
+4 1 0 50 -1 18 12 0.0000 4 105 330 4770 6255 aux\001
View
134 src/compiler/doc/midi.tex
@@ -19,14 +19,18 @@
\maketitle
+\begin{abstract}
+This document describes how MIDI
+\end{abstract}
+
+%\setcounter{tocdepth}{1}
+\tableofcontents
% -----------------------------------------------------------------------------
\section{Introduction}
-This document describes the architecture of the MIDI control @@@
-
Note that this work is still in progress. For example,
\begin{itemize}
\item the MIDI device specifications should not have to be part of
@@ -54,7 +58,7 @@ \section{Quick start}
but2 = button(17);
}
-sensitivity = linear(main);
+sensitivity = range(main);
per_frame:
wave_scale = sensitivity*10;
@@ -81,40 +85,97 @@ \section{Quick start}
\section{Architecture}
+When a MIDI device is1
+\begin{figure}[!tb]
+\begin{center}
+\includegraphics{arch.pdf}
+\end{center}
+\caption{Input event processing in Flickernoise.}
+\label{arch}
+\end{figure}
+
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-\subsection{MIDI control message}
+\subsection{MIDI control messages}
+
+A MIDI device sends a message each time one of its elements is actuated.
+There are various types of elements, keys, pitch wheels, controls, etc.
+Controls can be all sorts of things, including faders, potentiometers,
+and push buttons.
+
+For now, we only consider controls. When a control is actuated, the
+MIDI device generates a MIDI Control Change messages, as shown in
+figure \ref{msg}.
+
+\begin{figure}[!tb]
+\begin{center}
+\includegraphics{msg.pdf}
+\end{center}
+\caption{Anatomy of a MIDI Control Change message.}
+\label{msg}
+\end{figure}
+
+Channel numbers are encoded as values from 0 to 15 in the actual
+MIDI message but are commonly presented as 1 to 16 to the user.
+Also Flickernoise follows this convention.
-- MIDI: 0-127
+Most MIDI devices use a single channel. The number of this channel
+can sometimes be set by the user. The controller numbers are typically
+fixed.
+
+Flickernoise uses the message type, the channel number, and the controller
+number to determine where to send the value.
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-\subsection{...}
+\subsection{@@@}
+
+@@@
% -----------------------------------------------------------------------------
-\section{Configuration process}
+
+\section{Using controls in patches}
+
+@@@
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\subsection{Device database}
+The device database tells Flickernoise how to identify MIDI
+devices and how to
Device specifications are added to the device database with
- global section
+\begin{expose}
+{\tt midi} {\em identification} \verb"{" {\em element $\ldots$} \verb"}"
+\end{expose}
+
+Each element has the following syntax:
+
+\begin{expose}
+{\tt {\em name} =
+ {\em device\_type}($\left[\hbox{\em channel}\verb","\right]$
+ {\em control\_number});}
+\end{expose}
+
+{\em channel} is the MIDI channel number, from 1 to 16. If the channel
+is omitted, the element will match any channel.
+
\begin{listing}{1}
midi "dev1" {
main = fader(1, 102);
aux = pot(1, 103);
but1 = button(1, 16);
but2 = button(1, 17);
- tog = switch(1, 24);
+ sw = switch(1, 24);
}
\end{listing}
@@ -137,8 +198,9 @@ \subsection{Binding}
{\em control\_variable} can be a pre-defined per-frame or per-vertex
variable or it can be a user-defined variable. Variables that are
-updated by Flickernose itself, e.g., {\tt time} or {\tt bass}, cannot
-be used as control variables.
+updated by Flickernoise itself cannot be used as control variables.
+These variables are
+\input nocvars.inc
{\em function} describes how the patch expects the control to behave.
Flickernoise then tries to adapt the behaviour of the actual device
@@ -156,11 +218,10 @@ \subsection{Binding}
\item[\tt button]
The control variable receives the value 1 when the button is
pressed and returns to zero when it is released. When applied to
- elements that send values between 0 and 1, the value is rounded
- and the control acts like a {\tt switch}.
+ elements that send values between 0 and 1, the value is rounded.
\item[\tt switch]
- The value of the control variable changes between 0 and 1 each
- time the element -- typically a button -- is actuated.
+ The control variable can be set to 0 or 1 and retains the value
+ until the element is actuated again.
\end{description}
{\em element\_name} is the name of the control element, as in the
@@ -168,7 +229,7 @@ \subsection{Binding}
\begin{figure}[!tb]
\begin{center}
-\includegraphics{bind}
+\includegraphics{bind.pdf}
\end{center}
\caption{When binding a control variable, information from the device
database, a translation map, and the table of patch variables is
@@ -184,7 +245,7 @@ \subsection{Event processing}
\begin{figure}[!tb]
\begin{center}
-\includegraphics{stim}
+\includegraphics{stim.pdf}
\end{center}
\caption{When a MIDI control message is received, Flickernoise looks
for a matching stimulus and processes the value accordingly.}
@@ -211,11 +272,39 @@ \subsection{Event processing}
\subsection{Writing to control variables}
-- pfv
-- pvv
-- continuity
+A patch can overwrite the values control variables. In the case of
+per-frame variables, they retain their modified content across
+frames until a new event arrives. The new event will always overwrite
+the previous value of the variable without regard for any changes that
+may have been made.
+
+Changes to per-vertex variables are lost at the end of the program.
+
+It is sometimes desirable to make a control change a variable relative
+to a value set by the patch. The following example illustrates how
+this can be accomplished:
+
+\begin{listing}{1}
+cvar = range(foo);
+
+per_frame:
+ var = var+cvar-last;
+ last = cvar;
+ /* ... use "var" ... */
+ var = condition ? new_value : var;
+\end{listing}
+
+Instead of writing to the control variable {\tt cvar} directly, we
+propagate any relative changes of {\tt cvar} to {\tt var} in lines
+4 and 5, and only modify {\tt var} in line 7.
+
+Note that {\tt var} may assume values outside the range $0\ldots 1$.
+If this is not desirable, it can be clipped after line 4 with
+
+\begin{listing}{1}
+ var = max(min(var, 1), 0);
+\end{listing}
-exercised to avoid any of the per-defined variables that are updated
% -----------------------------------------------------------------------------
@@ -429,12 +518,11 @@ \subsection{Switches}
var = switch(name);
\end{listing}
-In the example below, we indicate whether the control is activated
-by a lamp next to the button:
+Switches behave the same for all functions:
\begin{expose}
\begin{tabular}{lcccl}
- \raisebox{6mm}{User input} &
+ \raisebox{4mm}{User input} &
\includegraphics{switch-off.pdf} &
\includegraphics{switch-on.pdf} &
\includegraphics{switch-off.pdf} \\
View
18 src/compiler/doc/mknocvars
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+#
+# mknocvars - Generate the list of variables forbidden as control variables
+#
+# Copyright 2012 by Werner Almesberger
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
+#
+
+sed 's/#.*//;/^ *$/d' $1 | LANG=C sort | {
+ while read n; do
+ echo "$n" | grep SF_LIVE >/dev/null || continue
+ set - $n
+ echo $1 | sed 's/[0-9]$/{\\em n}/'
+ done
+} | uniq | sed 's/_/\\_/g;s/.*/{\\tt &},/' | sed '${s/,$/./;s/^/and /;}'
View
39 src/compiler/doc/msg.fig
@@ -0,0 +1,39 @@
+#FIG 3.2 Produced by xfig version 3.2.5b
+Landscape
+Center
+Metric
+A4
+100.00
+Single
+-2
+1200 2
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 3375 1845 3375 2205
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 4275 1845 4275 2205
+2 1 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 5175 1845 5175 2205
+2 2 0 3 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 2475 1800 6075 1800 6075 2250 2475 2250 2475 1800
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 2925 1395 2925 1755
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 3825 1575 3825 1755
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 4725 1350 4725 1755
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 5625 1575 5625 1755
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 2925 2340 2925 2610
+4 1 0 50 -1 18 15 0.0000 4 180 360 2925 2115 CC\001
+4 1 0 50 -1 18 15 0.0000 4 180 270 5625 2115 28\001
+4 1 0 50 -1 18 15 0.0000 4 180 405 4725 2115 103\001
+4 1 0 50 -1 18 15 0.0000 4 180 135 3825 2115 0\001
+4 1 0 50 -1 18 12 0.0000 4 150 765 3825 1530 Channel\001
+4 1 0 50 -1 18 12 0.0000 4 150 525 5625 1530 Value\001
+4 1 0 50 -1 18 12 0.0000 4 135 480 4725 2520 0-127\001
+4 1 0 50 -1 18 12 0.0000 4 135 375 3825 2520 0-15\001
+4 1 0 50 -1 18 12 0.0000 4 135 480 5625 2520 0-127\001
+4 1 0 50 -1 18 12 0.0000 4 195 1455 3240 2790 Control Change\001
+4 1 0 50 -1 18 12 0.0000 4 150 930 4725 1305 Controller\001
+4 1 0 50 -1 18 12 0.0000 4 195 1260 2925 1305 Message type\001
View
4 src/compiler/doc/stim.fig
@@ -95,14 +95,14 @@ Single
4 1 0 50 -1 18 12 0.0000 4 150 480 2520 1440 Chan\001
4 1 0 50 -1 18 12 0.0000 4 135 105 2520 1890 1\001
4 1 0 50 -1 18 12 0.0000 4 150 330 3015 1440 Ctrl\001
-4 1 0 50 -1 18 12 0.0000 4 135 210 3060 1890 16\001
+4 1 0 50 -1 18 12 0.0000 4 135 315 3060 1890 103\001
4 1 0 50 -1 18 12 0.0000 4 135 210 3555 1890 28\001
4 1 0 50 -1 18 12 0.0000 4 150 525 3555 1440 Value\001
4 1 0 50 -1 18 12 0.0000 4 150 420 1125 1755 MIDI\001
4 1 0 50 -1 18 12 0.0000 4 195 450 3645 3780 Type\001
4 1 0 50 -1 18 12 0.0000 4 150 480 4185 3780 Chan\001
4 1 0 50 -1 18 12 0.0000 4 150 330 4680 3780 Ctrl\001
-4 1 0 50 -1 18 12 0.0000 4 135 210 4680 3555 16\001
+4 1 0 50 -1 18 12 0.0000 4 135 315 4680 3555 103\001
4 1 0 45 -1 18 12 0.0000 4 150 435 5130 3780 Proc\001
4 1 0 45 -1 18 12 0.0000 4 150 315 5535 3780 Var\001
4 1 0 50 -1 18 12 0.0000 4 135 480 7740 2340 0.220\001
View
18 src/compiler/doc/switch.fig
@@ -7,17 +7,17 @@ A4
Single
-2
1200 2
-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
-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
+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
+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
# on
-1 3 0 4 0 7 45 -1 49 0.000 1 0.0000 4590 4500 315 315 4590 4500 4905 4500
+1 3 0 4 0 7 45 -1 49 0.000 1 0.0000 4455 4500 405 405 4455 4500 4860 4500
# off
-1 3 0 4 0 7 45 -1 49 0.000 1 0.0000 4590 5400 315 315 4590 5400 4905 5400
+1 3 0 4 0 7 45 -1 49 0.000 1 0.0000 4455 5400 405 405 4455 5400 4860 5400
2 1 0 4 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 4275 4500 4275 5400
+ 4860 4500 4860 5400
2 1 0 4 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
- 4905 4500 4905 5400
+ 4050 4500 4050 5400
2 2 0 1 7 7 50 -1 -1 0.000 0 0 -1 0 0 5
- 4050 3915 6210 3915 6210 5985 4050 5985 4050 3915
-4 0 0 50 -1 18 28 0.0000 4 345 930 5175 5670 OFF\001
-4 0 0 50 -1 18 28 0.0000 4 345 690 5175 4545 ON\001
+ 3825 3870 6345 3870 6345 6075 3825 6075 3825 3870
+4 0 0 50 -1 18 32 0.0000 4 390 810 5175 4590 ON\001
+4 0 0 50 -1 18 32 0.0000 4 390 1080 5175 5715 OFF\001
View
49 src/gui/patcheditor.c
@@ -40,6 +40,31 @@ static struct filedialog *filesave_dlg;
static int modified;
static char current_filename[384];
+static char *protect_string(const char *s)
+{
+ int n = 0;
+ const char *p;
+ char *buf, *d;
+
+ for(p = s; *p; p++)
+ if(*p == '"')
+ n++;
+
+ buf = malloc(p-s+n+1);
+ if(!buf)
+ return NULL;
+
+ d = buf;
+ for(p = s; *p; p++) {
+ if(*p == '"')
+ *d++ = '\\';
+ *d++ = *p;
+ }
+ *d = 0;
+
+ return buf;
+}
+
static void update_wintitle(void)
{
const char *short_filename;
@@ -76,8 +101,8 @@ static void openok_callback(void *arg)
{
char buf[MAX_PATCH_SIZE+1];
FILE *fd;
- int r, n = 0;
- char *p, *d;
+ int r;
+ char *s;
get_filedialog_selection(fileopen_dlg,
current_filename, sizeof(current_filename));
@@ -99,25 +124,15 @@ static void openok_callback(void *arg)
}
buf[r] = 0;
- for(p = buf; *p; p++)
- if(*p == '"')
- n++;
- if(r+n > MAX_PATCH_SIZE) {
+ s = protect_string(buf);
+ if(!s) {
mtk_cmd(appid,
"status.set(-text \"No room to expand quotes\")");
return;
}
+ mtk_cmdf(appid, "ed.set(-text \"%s\")", s);
+ free(s);
- d = p+n;
- do {
- *d = *p;
- if(*p == '"')
- *--d = '\\';
- p--;
- }
- while(d-- != buf);
-
- mtk_cmdf(appid, "ed.set(-text \"%s\")", buf);
mtk_cmd(appid, "edf.expose(0, 0)");
}
@@ -174,7 +189,9 @@ static void saveasok_callback(void *arg)
static void rmc(const char *m)
{
+ m = protect_string(m);
mtk_cmdf(appid, "status.set(-text \"%s\")", m);
+ free((void *) m);
}
static void run_callback(mtk_event *e, void *arg)
View
22 src/renderer/stimuli.c
@@ -9,12 +9,16 @@
*/
#include <stddef.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "stimuli.h"
+static uint8_t midi_last[MIDI_CHANS][MIDI_CTRLS];
+
+
/* ----- Low-level register update ---------------------------------------- */
@@ -99,6 +103,8 @@ void stim_midi_ctrl(struct stimuli *s, int chan, int ctrl, int value)
{
struct s_midi_ctrl *ct;
+ midi_last[chan][ctrl] = value;
+
if(!s)
return;
@@ -185,6 +191,20 @@ void stim_put(struct stimuli *s)
free(s);
}
+static void reset_control(struct s_midi_ctrl *ct, int chan, int ctrl)
+{
+ void (*proc)(struct s_midi_ctrl *sct, int value);
+
+ proc = ct->proc;
+ if(!proc)
+ return;
+ if(proc == midi_proc_diff_cyclic || proc == midi_proc_diff_unbounded ||
+ proc == midi_proc_diff_linear)
+ proc(ct, 0);
+ else
+ proc(ct, midi_last[chan][ctrl]);
+}
+
void stim_redirect(struct stimuli *s, void *new)
{
int i, j;
@@ -204,6 +224,7 @@ void stim_redirect(struct stimuli *s, void *new)
ct->regs.pfv = (void *) ct->regs.pfv+d;
if(ct->regs.pvv)
ct->regs.pvv = (void *) ct->regs.pvv+d;
+ reset_control(ct, i, j);
}
}
s->target = new;
@@ -271,6 +292,7 @@ void stim_db_free(void)
free(db);
db = next;
}
+ last = &db;
}

No commit comments for this range

Something went wrong with that request. Please try again.