Giter Site home page Giter Site logo

Comments (1)

maltman23 avatar maltman23 commented on July 2, 2024

Sorry for taking so long to answer your question!

Its a good question. The answer is to be found in the example sketch _22_Amp_Modifiers.ino, but it should probably be made more explicit:

The reason setAttack() -- or any other setting of control parameters -- will not work when put in the setup() method of the synth is because they will all be wiped out any time the synth is reset. An implicit reset of the synth is conducted by the library at the end of the startup sequence, after setup() has been called -- hence those settings will be lost.

The proper place to put this kind of code is in the "reset handler" of the synth -- the logic which handles '!' in the charEv(char code) method of the synth.

One way to explain the difference between the code in the 'reset' portion of the synth's charEv() method, and the code in the setup() method is that the former is what gets executed in a soft reset (resetting after the power is already on), and the latter in a hard reset (when you first apply power).

The relevant lines from _22_Amp_Modifiers.ino start at line 238, and are reproduced here:

------------------- from _22_Amp_Modifiers.ino (line 238) --------------------

   // We initialize our controls in the reset handler for our synth. 
   //
   // The reset handler is the code which is executed when our synth receives
   // a '!' character event. 
   //
   // Note: ardutouch_setup() resets the synth before returning.
 
   boolean charEv( char code )
   {
      switch ( code )
      {
         case '!':                     // reset
         {
            // perform generic reset of the superclass
            
            super::charEv('!');

            //       the following macro will (line-by-line):

            // start keyboard in octave 5,
            // push voice 0 
            // set envelope (decay=68, sustain=64, release=100)
            // push amdMods
            // initialize tremolo control (freq=2.5hz, depth=1.0, unmute)
            // pop ampMods and pop voice 0

            console.exe( PSTR( "k5\\`"
                               "0"
                               "ed68\\s64\\r100\\`"
                               "A"
                               "tf2.5\\d1\\<`"
                               "``" ) );

            break;
         }
         default:
            return super::charEv( code );
      }
      return true;
   }

from ardutouch.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.