<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Modartt user forum - Standalone continuous sustain pedal?]]></title>
		<link>https://forum.modartt.com/viewtopic.php?id=3635</link>
		<description><![CDATA[The most recent posts in Standalone continuous sustain pedal?.]]></description>
		<lastBuildDate>Sun, 16 Aug 2015 13:17:53 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=939362#p939362</link>
			<description><![CDATA[<p>When the continuous sustain-pedal is unplugged, the analog input of the teensy2.0 microcontroller would be undefined, so I inserted a &quot;pull-down&quot; resistor (1 Megaohm) from wiper to ground. This guarantees sustain-off. And with a little luck, it evens false-positives from a scratchy wiper as a side-effect.</p><p><span class="postimg"><img src="http://fs1.directupload.net/images/150816/b2un2bed.jpg" alt="http://fs1.directupload.net/images/150816/b2un2bed.jpg" title="http://fs1.directupload.net/images/150816/b2un2bed.jpg"/></span></p><p>LATE PS:<br />I found a change-detection every 20 ms to be a better compromise, than 40 ms. This means some more CC64 MIDI-events, but on the other hand a better realtime response. A very fast pressed or released pedal should reach 127 or 0 in a reasonable time (with 40 ms for example it can happen, that full sustain 127 is reached after 81 ms,&nbsp; but this event is sent 39 ms later after 120 ms -- unnecessary lag)</p>]]></description>
			<author><![CDATA[null@example.com (groovy)]]></author>
			<pubDate>Sun, 16 Aug 2015 13:17:53 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=939362#p939362</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=939067#p939067</link>
			<description><![CDATA[<p>Much of the point I was trying to make is that we don&#039;t know what needs to be filtered out until we know what is actually there.<br />Consumer grade pedals are unlikely to have high grade components, so it is LIKELY that they will produce spikes.<br />What I think worth doing is to hook up the pedal(s) that you have and look at the midi stream with no filtering.<br />Watch it when clamped at about half pedal, when fully pressed and when released.<br />Press it slowly, release it slowly, capture that midi stream and look for SMOOTH transitions.<br />Also sudden stomps and releases.<br />If you see sudden jumps and/or bounces you will need to filter - for THAT pedal.</p><p>My playing barely needs more than a switched damper pedal anyway, so I have only an interest in this based on my electronics background.</p>]]></description>
			<author><![CDATA[null@example.com (aandrmusic)]]></author>
			<pubDate>Sat, 25 Jul 2015 10:46:10 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=939067#p939067</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=939053#p939053</link>
			<description><![CDATA[<p>Hi,</p><div class="quotebox"><cite>sleepydog wrote:</cite><blockquote><p>I don&#039;t know how fast this fluttering is and how much of an *audible* change from e.g. 126 to 127 does.</p></blockquote></div><p>it is not audible, we only don&#039;t want to pollute the midi-bus with unnecessary midi-events. In the <strong>worst&nbsp; case</strong> two values could &quot;flutter&quot; with the sample-frequency of the ADC.</p><p>But If you read the thread thoroughly we already found several working solutions:</p><p>a) <a href="http://www.forum-pianoteq.com/viewtopic.php?pid=938384#p938384">http://www.forum-pianoteq.com/viewtopic...84#p938384</a><br />b) <a href="http://www.forum-pianoteq.com/viewtopic.php?pid=938388#p938388">http://www.forum-pianoteq.com/viewtopic...88#p938388</a><br />c) <a href="http://www.forum-pianoteq.com/viewtopic.php?pid=938475#p938475">http://www.forum-pianoteq.com/viewtopic...75#p938475</a><br />d) <a href="http://www.forum-pianoteq.com/viewtopic.php?pid=938617#p938617">http://www.forum-pianoteq.com/viewtopic...17#p938617</a></p><p>I prefer the last solution d) (teensy2.0) and I&#039;m using it a few weeks now with my continuous sustain-pedal and with great success. No problems or glitches at all!</p><p>Most of your suggestions are already implemented there, if you read the code:</p><p>- circular buffer of 10 samples.<br />- average of the 10 samples (&quot;smoothing&quot;)<br />- sample-interval ~1ms<br />- change detection every ~40 ms if sustain delta is &gt; 1</p><p>The only not implemeted &quot;feature&quot; is aandrmusic&#039;s idea of extreme spike-detection and -dropping.</p><div class="quotebox"><cite>sleepydog wrote:</cite><blockquote><p>Seeing this thread here, tells me, it must be possible in Pianoteq to have more than one MIDI input device, each for a different purpose?</p></blockquote></div><p>Yes, Pianoteq can use several midi-devices simultaneously. For example I have listed two midi-devices in Pianoteq Standard: My Teensy2.0 continuous sustain-pedal and my USB-keyboard-controller.</p><div class="quotebox"><cite>sleepydog wrote:</cite><blockquote><p>I don&#039;t know the Arduino platform and the quality of its ADCs, though.</p></blockquote></div><p>... both the Arduino nano and the Teensy2.0 have 10-bit ADC (0-1023). That&#039;s why I divide by 8 to get (0-127).</p><p>cheers</p>]]></description>
			<author><![CDATA[null@example.com (groovy)]]></author>
			<pubDate>Fri, 24 Jul 2015 21:25:41 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=939053#p939053</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=939050#p939050</link>
			<description><![CDATA[<div class="quotebox"><cite>aandrmusic wrote:</cite><blockquote><p>I see little/no point in mere &quot;Smoothing&quot; of suspect values.</p></blockquote></div><p>Well, averaging pot ADC input is not uncommon. Since I don&#039;t know his exact setup / circuit, it was one thing he could try. But the plastic box + wild wires looked noisy enough ;-)<br />It helped in a few things I built against small but constantly present fluctuatuations due to external noise when pots remained untouched (front panel).<br />I have no experience with filtering wild expression pedal action ;-)<br />Or with the output of hall sensors, for that matter. I imagine it would be less &quot;fractured&quot; than potentiometers&#039;.</p><p>Having an adequate analog input filter before the ADC is half the rent, anyway.</p><div class="quotebox"><blockquote><p>Noise from potentiometer wipers is likely to be in the form of spikes (both negative and positive) and could last for milliseconds.</p></blockquote></div><p>You mean like from an old pot, sudden discontinuations in the surface? Is it really the duty of the software to fix pots which should be replaced? ^^ Well I guess making them live a little longer might be worth it.<br />But last for several ms? How that? I would hardly call that spikes then, given the rate of change we&#039;re talking about here.<br />I haven&#039;t seen anything like that so far, maybe because I haven&#039;t used anything I built so extensively that the pots could be worn out.</p><div class="quotebox"><blockquote><p>I regard suspect values as anything wildly different from a recent average, those should be discarded immediately, not put with recent valid values to pollute the valid average.</p></blockquote></div><p>Sounds reasonable, I&#039;ll keep that strategy in the back of my head for the time I ever encounter huge jumps and the offending pot is &quot;mostly good&quot; still - *if* it is. And try to balance this against proper reading of quick real changes.</p><p>As for the foot not moving so fast, well it can be quite fast. If I kick the pedal, the travel might be well under 10ms for a full scale jump, easily under 20ms. I&#039;d certainly not just discard such a jump.</p><div class="quotebox"><blockquote><p>Clearly differences of 1 need to be filtered out since they can occur from rounding no matter how good the sensor is, this is the plus or minus half the least significant bit problem that ALL analogue to digital conversion has.</p></blockquote></div><p>Sure, the n * LSB error of the ADC alone should not spoil the game here, though, if maybe a not too crappy 10 bit ADC is used when only 7-bit output is needed.<br />I don&#039;t know the Arduino platform and the quality of its ADCs, though.</p><p>Now that I know Pianoteq can use this, I&#039;ll certainly solder something together and try how well it works ;-)<br />I wonder what the heck the FATAR guys were thinking when giving my SL990 a on/off pedal input ;-)</p><div class="quotebox"><blockquote><p>Yes, pianoteq can be set to listen on all midi inputs, for example mine is set to listen to midi cable and to loopBE internal midi.<br />Also many/most midi devices have &quot;midi in&quot; and &quot;midi through&quot;, so you can &quot;daisy chain&quot; midi devices.</p></blockquote></div><p>Thanks! Now I only need to learn to play the piano properly :-D :-D</p>]]></description>
			<author><![CDATA[null@example.com (sleepydog)]]></author>
			<pubDate>Fri, 24 Jul 2015 20:00:56 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=939050#p939050</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=939039#p939039</link>
			<description><![CDATA[<div class="quotebox"><cite>sleepydog wrote:</cite><blockquote><p>Hey there, just registered,<br />have pianoteq for a while, saw a DIY thread and well, then I just had to register :-D</p><p>I have 1) a suggestion and 2) a question</p><p>1) value fluttering</p><p>I don&#039;t know how fast this fluttering is and how much of an *audible* change from e.g. 126 to 127 does.<br />Does the value e.g. 126 or 127 sometimes stay for a long time and then it flips to the other number, stays for a long time and flips again? Depending on the audible change it wouldn&#039;t be too bad perhaps.<br />But if it indeed changes &quot;reliably&quot; between a few very close values, with no long pauses, maybe some sort of low-pass filtering would help?<br />Which means no values in the range, and no deltas are excluded from the output categorically, just that time is factored in there.</p><p>I&#039;m not quite a DSP guru, only have very fractional knowledge there.<br />But IIRC, the simplest form of low pass, which might work here, would be just to average a box of values.<br />Say, you have a circular buffer of size 3 (perhaps sufficient, perhaps needs to be bigger). In this case it would make sense I guess to put one new value in the buffer and discard the oldest *one* (you could also move about other lengths over the input stream, but intuitively I&#039;d say that makes no sense here).<br />You average all values in the buffer, and pass on the result of that, which should be more stable than the fluttering input. If 3 is not stable enough, try 4..5.. etc).</p><p>Example:<br />The input stream of Sustain events: {126,125,127,125,126,127,126}<br />Output stream of averages (with fractional part | rounded by 0.5)<br />(After program start, when the first CC event arrives, I guess you need to fill the buffer initially completely with the first ever received value before generating the first output event. After that, each new incoming event just does the regular step: &quot;put newest into buffer, discard oldest from buffer, average all, generate output event&quot;)<br />{126,126,126} -&gt; 126&nbsp; &nbsp; | 126<br />{126,126,125} -&gt; 125.6 | 126<br />{126,125,127} -&gt; 126&nbsp; &nbsp; | 126<br />{125,127,125} -&gt; 125.6 | 126<br />{127,125,126} -&gt; 126&nbsp; &nbsp; | 126<br />{125,126,127} -&gt; 126&nbsp; &nbsp; | 126<br />{126,127,126} -&gt; 126.3 | 126</p><p>As you see, the rounded output remains stable. This depends of course on how widely and with what kind of distribution the input fluctuates and how many values the averaging buffer has.<br />But differences of (on average) 1 are still possible, which it would not with a solution like &quot;only pass deltas &gt;= 4&quot; or so.<br />E.g., if it fluctuates, say, around 125 +/-1, and you kick the pedal fully, and it fluctuates around 126 +/-1.</p><br /><p>2) Pianoteq and extra MIDI Sustain pedal as own MIDI device</p><p>Seeing this thread here, tells me, it must be possible in Pianoteq to have more than one MIDI input device, each for a different purpose?<br />E.g. use my MIDI keyboard which does not have a continuous sustain pedal input for notes, and a Pedal as own MIDI device as pedal input?<br />Can someone tell me how to set this up in Pianoteq 5? (I think I have the cheapest version...)</p></blockquote></div><p>I see little/no point in mere &quot;Smoothing&quot; of suspect values.<br />Noise from potentiometer wipers is likely to be in the form of spikes (both negative and positive) and could last for milliseconds. <br />I regard suspect values as anything wildly different from a recent average, those should be discarded immediately, not put with recent valid values to pollute the valid average.&nbsp; At first guess any change greater than 10% of the current average is too large and has happened too fast to be valid - feet can&#039;t move that fast.<br />In view of the times scales involved, e.g. feet move on a time scale of fractions of a second, but code runs around loops in microseconds - any averaging buffers could be quite LARGE.&nbsp; The arduino might as well be doing this filtering instead of sitting on a wait for tens of milliseconds.</p><p>Clearly differences of 1 need to be filtered out since they can occur from rounding no matter how good the sensor is, this is the plus or minus half the least significant bit problem that ALL analogue to digital conversion has.<br />Beyond that, sad to say it depends on the particular sensor in each particular pedal, i.e. if you use a 3 pedal unit such as the RPU-3 it would be wise to gather data for each pedal and set your filters to each one.&nbsp; If you PLAN to do this the code should be simple enough.<br />My guess is that a cyclic list 64 or 128 locations long might be a good starting place.<br />From there experimentation is needed, again with the particular pedals that you are using as well as the processing speed of the arduino and its libraries.</p><br /> <br /><p>Yes, pianoteq can be set to listen on all midi inputs, for example mine is set to listen to midi cable and to loopBE internal midi.<br />Also many/most midi devices have &quot;midi in&quot; and &quot;midi through&quot;, so you can &quot;daisy chain&quot; midi devices.</p>]]></description>
			<author><![CDATA[null@example.com (aandrmusic)]]></author>
			<pubDate>Fri, 24 Jul 2015 13:45:59 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=939039#p939039</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=939038#p939038</link>
			<description><![CDATA[<p>Hey there, just registered,<br />have pianoteq for a while, saw a DIY thread and well, then I just had to register :-D</p><p>I have 1) a suggestion and 2) a question</p><p>1) value fluttering</p><p>I don&#039;t know how fast this fluttering is and how much of an *audible* change from e.g. 126 to 127 does.<br />Does the value e.g. 126 or 127 sometimes stay for a long time and then it flips to the other number, stays for a long time and flips again? Depending on the audible change it wouldn&#039;t be too bad perhaps.<br />But if it indeed changes &quot;reliably&quot; between a few very close values, with no long pauses, maybe some sort of low-pass filtering would help?<br />Which means no values in the range, and no deltas are excluded from the output categorically, just that time is factored in there.</p><p>I&#039;m not quite a DSP guru, only have very fractional knowledge there.<br />But IIRC, the simplest form of low pass, which might work here, would be just to average a box of values.<br />Say, you have a circular buffer of size 3 (perhaps sufficient, perhaps needs to be bigger). In this case it would make sense I guess to put one new value in the buffer and discard the oldest *one* (you could also move about other lengths over the input stream, but intuitively I&#039;d say that makes no sense here).<br />You average all values in the buffer, and pass on the result of that, which should be more stable than the fluttering input. If 3 is not stable enough, try 4..5.. etc).</p><p>Example:<br />The input stream of Sustain events: {126,125,127,125,126,127,126}<br />Output stream of averages (with fractional part | rounded by 0.5)<br />(After program start, when the first CC event arrives, I guess you need to fill the buffer initially completely with the first ever received value before generating the first output event. After that, each new incoming event just does the regular step: &quot;put newest into buffer, discard oldest from buffer, average all, generate output event&quot;)<br />{126,126,126} -&gt; 126&nbsp; &nbsp; | 126<br />{126,126,125} -&gt; 125.6 | 126<br />{126,125,127} -&gt; 126&nbsp; &nbsp; | 126<br />{125,127,125} -&gt; 125.6 | 126<br />{127,125,126} -&gt; 126&nbsp; &nbsp; | 126<br />{125,126,127} -&gt; 126&nbsp; &nbsp; | 126<br />{126,127,126} -&gt; 126.3 | 126</p><p>As you see, the rounded output remains stable. This depends of course on how widely and with what kind of distribution the input fluctuates and how many values the averaging buffer has.<br />But differences of (on average) 1 are still possible, which it would not with a solution like &quot;only pass deltas &gt;= 4&quot; or so.<br />E.g., if it fluctuates, say, around 125 +/-1, and you kick the pedal fully, and it fluctuates around 126 +/-1.</p><br /><p>2) Pianoteq and extra MIDI Sustain pedal as own MIDI device</p><p>Seeing this thread here, tells me, it must be possible in Pianoteq to have more than one MIDI input device, each for a different purpose?<br />E.g. use my MIDI keyboard which does not have a continuous sustain pedal input for notes, and a Pedal as own MIDI device as pedal input?<br />Can someone tell me how to set this up in Pianoteq 5? (I think I have the cheapest version...)</p>]]></description>
			<author><![CDATA[null@example.com (sleepydog)]]></author>
			<pubDate>Fri, 24 Jul 2015 13:03:35 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=939038#p939038</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=938625#p938625</link>
			<description><![CDATA[<div class="quotebox"><cite>aandrmusic wrote:</cite><blockquote><p>Yes, it is likely to be LARGE and PERSISTENT, i.e. bounce around for milliseconds.</p></blockquote></div><p>... one more reason for contactless Hall-Sensors ...</p><p>Thank you! ;-)</p><p><span class="postimg"><img src="http://fs1.directupload.net/images/150628/hy4bwkij.jpg" alt="http://fs1.directupload.net/images/150628/hy4bwkij.jpg" title="http://fs1.directupload.net/images/150628/hy4bwkij.jpg"/></span></p>]]></description>
			<author><![CDATA[null@example.com (groovy)]]></author>
			<pubDate>Sun, 28 Jun 2015 13:47:05 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=938625#p938625</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=938621#p938621</link>
			<description><![CDATA[<div class="quotebox"><cite>groovy wrote:</cite><blockquote><p>Do we have any indication, that the deviation by bouncing/settling is <strong>not</strong> masked by the hysteresis of +/-2 MIDI-values?</p><p>And <strong>if</strong> that noise couldn&#039;t be masked all the time - would it have practical consequences?</p><br /><div class="quotebox"><cite>aandrmusic wrote:</cite><blockquote><p>I will stream in raw values once I get hardware set up.</p></blockquote></div><p>Yes, statistics and simulation could give an answer.</p></blockquote></div><p>Yes, it is likely to be LARGE and PERSISTENT, i.e. bounce around for milliseconds.<br />The very existence of the code that you pointed to here;&nbsp; <a href="https://www.arduino.cc/en/Tutorial/Smoothing">https://www.arduino.cc/en/Tutorial/Smoothing</a> <br />supports the need for what I described earlier as maintaining a cyclic list of values and discarding values<br />that deviate a lot from the running average - different terms, but essentially the same basis and principles.<br />Spurious signals need to be filtered out, not just accepted at larger time intervals.<br />&nbsp; <br />Again, micro processors are fast, pots bounce slowly, feet move even slower.</p><p>There is no hysteresis, use of that term will likely lead to other readers becoming confused.</p>]]></description>
			<author><![CDATA[null@example.com (aandrmusic)]]></author>
			<pubDate>Sun, 28 Jun 2015 10:15:27 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=938621#p938621</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=938617#p938617</link>
			<description><![CDATA[<p>Both codes are married now. My simple code of 17-06-2015 23:11 and the Smoothing-example from the Tutorial.</p><p>In words it does the following: It checks every 40 ms, if an average of the last ten CC64-values has changed for more than &gt;= 2. In that case a MIDI-Event is sent to Pianoteq via USB (else not).</p><p>The analog input is read continuously every ~1 ms (because the loop has the delay(1)). So the ten readings in the cyclic list represent the last ~10 ms before the change-check.</p><div class="codebox"><pre><code>/* USB MIDI AnalogControlChange Example

   You must select MIDI from the &quot;Tools &gt; USB Type&quot; menu
   http://www.pjrc.com/teensy/td_midi.html

   This example code is in the public domain.
*/

#include &lt;Bounce.h&gt;

// the MIDI channel number to send messages
const int channel = 1;

// the MIDI continuous controller for each analog input
const int controllerA0 = 64; // 64 = sustain

const int numReadings = 10;

int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average

int inputPin = A0;

void setup() {
        // initialize all the readings to 0:
        for (int thisReading = 0; thisReading &lt; numReadings; thisReading++)
          readings[thisReading] = 0;
}

// store previously sent values, to detect changes
int previousA0 = -1;

elapsedMillis msec = 0;

void loop() {
  // subtract the last reading:
  total= total - readings[index];        
  // read from the sensor:  
  readings[index] = analogRead(inputPin);
  // add the reading to the total:
  total= total + readings[index];      
  // advance to the next position in the array:  
  index = index + 1;                    

  // if we&#039;re at the end of the array...
  if (index &gt;= numReadings)              
    // ...wrap around to the beginning:
    index = 0;                          

  // calculate the average:
  average = total / numReadings;        
  
  // only check for changes all 40 ms
  // to prevent a flood of MIDI messages
  if (msec &gt;= 40) {
    msec = 0;
    int n0 = average / 8;
    // only transmit MIDI messages if analog input changed
    // if (n0 != previousA0) {
    // only transmit MIDI if change is 2 or more
    int diff = abs (n0 - previousA0);
    if (diff &gt; 1) {
      usbMIDI.sendControlChange(controllerA0, n0, channel);
      previousA0 = n0;
    }
      delay(1);        // delay in between reads for stability
  }

  // MIDI Controllers should discard incoming MIDI messages.
  // http://forum.pjrc.com/threads/24179-Teensy-3-Ableton-Analog-CC-causes-midi-crash
  while (usbMIDI.read()) {
    // ignore incoming messages
  }
}</code></pre></div><p>At first glance it seems not to behave differently to the simplistic approach, but it should smoothen potential noise.</p>]]></description>
			<author><![CDATA[null@example.com (groovy)]]></author>
			<pubDate>Sat, 27 Jun 2015 17:18:59 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=938617#p938617</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=938616#p938616</link>
			<description><![CDATA[<p>Do we have any indication, that the deviation by bouncing/settling is <strong>not</strong> masked by the hysteresis of +/-2 MIDI-values?</p><p>And <strong>if</strong> that noise couldn&#039;t be masked all the time - would it have practical consequences?</p><br /><div class="quotebox"><cite>aandrmusic wrote:</cite><blockquote><p>I will stream in raw values once I get hardware set up.</p></blockquote></div><p>Yes, statistics and simulation could give an answer.</p>]]></description>
			<author><![CDATA[null@example.com (groovy)]]></author>
			<pubDate>Sat, 27 Jun 2015 08:10:26 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=938616#p938616</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=938612#p938612</link>
			<description><![CDATA[<p>Well, I have only a 3D printer experience with Arduino Mega, so I am having to draw on other experience with analogue signals, the very NATURE of potentiometers, also some A to D electronics background from a previous life.<br />Plus I have barely touched the Arduino code for that printer, so my &quot;experience&quot; is very limited.</p><p>A point about your last reply; Sure there is little/no noise when the pedal is stationary, as depicted with a clamp on it - but your code senses a change and assumes the value to be valid IMMEDIATELY.&nbsp; The point being that these initial change values are probably the MOST invalid. </p><p>Potentiometer wipers tend to BOUNCE and their settling time is typically in milliseconds.<br />Arduino&#039;s time to ReadAnalogue() is about 100 microseconds according to the reference page.<br />That seems awfully SLOW to me, but the exact time doesn&#039;t matter, it is an order of magnitude faster than the settling time of a potentiometer, so you could get around a read loop several times while a pot finds its steady value.<br />This is my main point, the arduino can be WATCHING the settling of the pot instead of WAITING some arbitrary amount of time to gather a next value that is no more credible, it is merely &quot;different&quot; and some number of milliseconds later.</p><p>I will stream in raw values once I get hardware set up.<br />It shouldn&#039;t take long to establish settling times and noise floors/ceilings, then I can decide if any of this matters more than my lack of pianistic skills - - Oh, I know that already.&nbsp; I need to PLAY more and PRACTICE more diligently.<br />&nbsp; &nbsp;<br />BTW, a 10 bit A to D should take little more than 10 clock cycles, that is why I think 100 microseconds is SLOW.</p>]]></description>
			<author><![CDATA[null@example.com (aandrmusic)]]></author>
			<pubDate>Sat, 27 Jun 2015 01:45:39 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=938612#p938612</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=938602#p938602</link>
			<description><![CDATA[<p>Calculating &quot;running averages&quot; probably would be the best solution, ack.&nbsp; </p><div class="quotebox"><cite>aandrmusic wrote:</cite><blockquote><p>[...]when the amount of noise isn&#039;t known.</p></blockquote></div><p>... but that is an important point IMHO. Maybe the noise of the analog input is negligible. For example all MIDI-events are stable, when I use fixed positions :-)<br />--&gt;<br /><span class="postimg"><img src="http://fs1.directupload.net/images/150626/2dbtdyxa.jpg" alt="http://fs1.directupload.net/images/150626/2dbtdyxa.jpg" title="http://fs1.directupload.net/images/150626/2dbtdyxa.jpg"/></span></p><p>Remains &quot;dynamic noise&quot; - is there any generated, when the pedal is moving dynamically up and down? I don&#039;t know, all I can say is, that I don&#039;t find any spikes in the opposite direction of the pedal movement&nbsp; (the deeper the pedal is pressed, the greater are the CC64-values in the event-list and vice versa). </p><div class="quotebox"><cite>aandrmusic wrote:</cite><blockquote><p> i.e. it is not &quot;qualified&quot; as good signal.</p></blockquote></div><p>But that doesn&#039;t mean, that it is not &quot;good enough&quot;. Ok, &quot;qualified&quot; would be better approach, yes. It would be interesting to see, how averaging handles fast 0 &lt;-&gt; 127 movements or erratic changes in between.</p><p>I&#039;m an absolut beginner with Teensy or Arduino, probably &quot;smoothing&quot; of the analog input would be the next step:</p><p><a href="https://www.arduino.cc/en/Tutorial/Smoothing">https://www.arduino.cc/en/Tutorial/Smoothing</a></p><p>(... where overengineering begins?? ;-)</p>]]></description>
			<author><![CDATA[null@example.com (groovy)]]></author>
			<pubDate>Fri, 26 Jun 2015 20:54:19 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=938602#p938602</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=938584#p938584</link>
			<description><![CDATA[<p>I have a &quot;philosophical problem&quot; with an approach of not sampling noisy analogue signals too often on the grounds that it generates too many changes, i.e. too much message traffic, especially when the amount of noise isn&#039;t known.<br />It acknowledges that there may be noise and that the &quot;Solution&quot; is to not listen as often.<br />It is a gamble, you may get a noise spike, a gap valley, or genuine signal - - but using that anyway, then coming back some fixed time interval later and selecting another unknown is just WRONG {IMO, etc.}.<br />Sure, it reduces traffic, but the traffic it sends is suspect at best, i.e. it is not &quot;qualified&quot; as good signal.</p><p>I would prefer an approach that samples as often as possible and actively FILTERS OUT noise.</p><p>Propose;<br />Sample as often as possible.<br />Store values in a cyclic list (length TBD experimentally)<br />Discard values that differ from previous table average by more than some percentage.<br />If table average has changed more than some TBD value Send table average, update previous table average, etc.</p><p>This would provide some smoothing as well as spike and valley noise removal.</p><p>I can&#039;t DO this until I have parts assembled, but I will run with NO filtering initially to determine the amount of noise on my pedals and the maximum speed at which my foot can perform full strokes - down is almost certainly faster than release.<br />Then I can determine table size and thresholds for discarding spikes and valleys.</p>]]></description>
			<author><![CDATA[null@example.com (aandrmusic)]]></author>
			<pubDate>Fri, 26 Jun 2015 11:26:24 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=938584#p938584</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=938475#p938475</link>
			<description><![CDATA[<div class="quotebox"><cite>aandrmusic wrote:</cite><blockquote><p>Almost worth getting one so I can tell people what it is when they ask <i class="far fa-laugh smiley"></i></p><p>Teensyduino</p><p>Seriously, I like it and might build with it.<br />The picture shows that it isn&#039;t much bigger than the end of the USB cable.</p></blockquote></div><p>:-) As you suggested, I modified the code a bit now, so that not each controller change is detected, but only if it is greater than 1 MIDI-value (i.e. 2, 3, 4, ...). This &quot;hysteresis&quot; is enough to make each pedal-position of my Roland DP-10 stable. As we discussed, it can happen now, that with a let-off pedal the cc64 remains at value 1 (and not 0).</p><p>But this is no problem, because Pianoteq drops all values &lt;=10 to value 0, and all values &gt;=117 to value 127 when calibrating the pedalcurve with the calibrator.&nbsp; </p><p>FYI:<br /></p><div class="codebox"><pre><code>/* USB MIDI AnalogControlChange Example

   You must select MIDI from the &quot;Tools &gt; USB Type&quot; menu
   http://www.pjrc.com/teensy/td_midi.html

   This example code is in the public domain.
*/

#include &lt;Bounce.h&gt;

// the MIDI channel number to send messages
const int channel = 1;

// the MIDI continuous controller for each analog input
const int controllerA0 = 64; // 64 = sustain

void setup() {
}

// store previously sent values, to detect changes
int previousA0 = -1;

elapsedMillis msec = 0;

void loop() {
  // only check the analog inputs all 40 ms
  // to prevent a flood of MIDI messages
  if (msec &gt;= 40) {
    msec = 0;
    int n0 = analogRead(A0) / 8;
    // only transmit MIDI messages if analog input changed
    // if (n0 != previousA0) {
    // only transmit MIDI if change is 2 or more
    int diff = abs (n0 - previousA0);
    if (diff &gt; 1) {
      usbMIDI.sendControlChange(controllerA0, n0, channel);
      previousA0 = n0;
    }
  }

  // MIDI Controllers should discard incoming MIDI messages.
  // http://forum.pjrc.com/threads/24179-Teensy-3-Ableton-Analog-CC-causes-midi-crash
  while (usbMIDI.read()) {
    // ignore incoming messages
  }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (groovy)]]></author>
			<pubDate>Wed, 17 Jun 2015 21:11:06 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=938475#p938475</guid>
		</item>
		<item>
			<title><![CDATA[Re: Standalone continuous sustain pedal?]]></title>
			<link>https://forum.modartt.com/viewtopic.php?pid=938463#p938463</link>
			<description><![CDATA[<p>Almost worth getting one so I can tell people what it is when they ask <i class="far fa-laugh smiley"></i></p><p>Teensyduino</p><p>Seriously, I like it and might build with it.<br />The picture shows that it isn&#039;t much bigger than the end of the USB cable.</p>]]></description>
			<author><![CDATA[null@example.com (aandrmusic)]]></author>
			<pubDate>Wed, 17 Jun 2015 02:37:03 +0000</pubDate>
			<guid>https://forum.modartt.com/viewtopic.php?pid=938463#p938463</guid>
		</item>
	</channel>
</rss>
