Skip to content

Commit

Permalink
Updated Beatitude, bug fixes in RealTimeSequencer in library, new dem…
Browse files Browse the repository at this point in the history
…o video

=== RELEASE 1.14 ===

This release is all about Beatitude and the RealTimeSequencer class  in the library.

The new version of Beatitude has these added features:
   1. The drum kit is now panned in stereo.
   2. The top pot controls the balance between the drum kit and the bass.
   3. When recording a sequence with prior versions of Beatitude the 1st
      drum hit was often missed if it happened "right before" the 1st beat
      of the 1st measure. This has been fixed.
   4. Fixed problems with sequence playback via changes to the RealTimeSequencer
         class in the library (see below).

RealTimeSequencer::jiffsToTrans is relaxed to the duration of a sixteenth note (was 1 juff)
         the following fixes to the RealTimeSequencer class ...
         bugfix: super was type-defed as Sequencer instead of SequencerRAM!
         bugfix: multiple key events during transition no longer cause haywire record compilation
         bugfix: :evHandler() no longer compiles bogus rest records
         bugfix: when dynamics() concatenated a rest it was not checking for an empty buffer

The last release (1.13) fixed the long-running problem in both Beatitude and Mantra
which caused both to behave bizarrely at times depending on what prior sketch had
 been loaded in the ROM. In the case of Beatitude it turns out that this problem (which
 was caused by a routine being called from the constructor of a static instantiation of the Beatitude synth before the library had been initialized -- and on which it depended) was
masking other serious issues: this new version of the library fixes not 1, not 2, not 3,
but 4 different bugs involving  corner cases in the RealTimeSequencer class.

The only items that are updated in this relase are: the Beatitude synth and the
library -- everything else remains the same.

I also added a video demo of Mitch playing 7 ArduTouch synths at once.
  • Loading branch information
maltman23 committed Jan 22, 2020
1 parent 4d8bc7d commit 8175655
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 118 deletions.
Binary file modified Arduino/Beatitude/Beatitude -- How to Use.pdf
Binary file not shown.
162 changes: 116 additions & 46 deletions Arduino/Beatitude/Beatitude/Beatitude.ino
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
// left button).
//
//
// ----------- Adjusting the Bass Volume -----------
//
//
// Rotate the top pot to make the bass louder or softer.
//
//
// ----------- Controlling the Tempo -----------
//
// Rotate the bottom pot to slow down or speed up the tempo.
Expand Down Expand Up @@ -145,6 +151,8 @@

#include "ArduTouch.h" // use the ArduTouch library

about_program( Beatitude, 1.10h ) // specify sketch name & version

#ifndef __STNDLONE__
#error This sketch requires the __STNDLONE__ runtime model (Model.h)
#endif
Expand All @@ -153,8 +161,6 @@
#error This sketch requires IMPLICIT_SEQUENCER to be defined (Model.h)
#endif

about_program( Beatitude, 1.06 ) // specify sketch name & version

/*----------------------------------------------------------------------------*
* presets
*----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -263,6 +269,11 @@ class DrumKit : public Voice

public:

// the panning coefficient

bool panRight; // if true pan to right (else, pan to left)
word panCoeff; // panning coefficient (for opposite channel)

DrumKit()
{
useSequencer( new RealTimeSequencer( 120 ) );
Expand Down Expand Up @@ -294,38 +305,55 @@ void DrumKit::noteOn( key note )
SampleOsc *o = (SampleOsc *)osc;
byte pos = note.position();

panCoeff = 128;

#ifdef USE_SERIAL_PORT // use reduced kit when the console is enabled

if ( pos <= 4 )

{
o->setSample( wavetable( lofi_Kick02 ) );

panRight = false;
panCoeff = 154;
}
else

{
o->setSample( wavetable( Snare01 ) );
panRight = true;
panCoeff = 154;
}

#else // use full kit

if ( pos <= 2 )

{
o->setSample( wavetable( lofi_Kick02 ) );

panRight = false;
panCoeff = 154;
}
else if ( pos <= 4 )

{
o->setSample( wavetable( lofi_Tom02 ) );

panRight = false;
panCoeff = 90;
}
else if ( pos <= 7 )

{
o->setSample( wavetable( Snare01 ) );

panRight = true;
panCoeff = 154;
}
else if ( pos <= 9 )

{
o->setSample( wavetable( Rim01 ) );

panRight = true;
panCoeff = 120;
}
else

{
o->setSample( wavetable( Hat03 ) );

panRight = true;
panCoeff = 85;
}
#endif

trigger();
Expand Down Expand Up @@ -379,10 +407,14 @@ class Beatitude : public VoxSynth
bool cueing; // if true, sequencer is cueing to record
bool liveBass; // if true, bass is being played live

byte scaleBass; // scale factor for bass (128 = 50%)

ClickTrack *click; // ptr to click track
DrumKit *drums; // ptr to drumkit voice
Bass *bass; // ptr to bass voice

RealTimeSequencer *sqnc; // synonym for drums->sqnc;

public:

void config()
Expand All @@ -394,6 +426,8 @@ class Beatitude : public VoxSynth
keybrd.setTopOct( 2 ); // constrain keyboard to octaves 0-2
keybrd.setDefOct( 1 ); // start keyboard in octave 1

sqnc = (RealTimeSequencer *)drums->sqnc;

presets.load( myPresets );
}

Expand Down Expand Up @@ -461,7 +495,6 @@ bool Beatitude::charEv( char code )

case sqncRECON: // sequencer recording switched on

drums->setMute( false ); // unmute
setCueing( false );
blinkLED( 1 ); // blink to indicate recording
break;
Expand Down Expand Up @@ -493,7 +526,7 @@ bool Beatitude::charEv( char code )
switch ( sqncNum )
{
case 0:
drums->sqnc->load( beat0 );
sqnc->load( beat0 );
break;
default:
break;
Expand All @@ -502,9 +535,9 @@ bool Beatitude::charEv( char code )
break;
}

case '[':
case '[': // start the sequencer

drums->sqnc->start();
sqnc->start();
break;

case '!': // perform a reset
Expand All @@ -516,9 +549,9 @@ bool Beatitude::charEv( char code )
setCueing( false );
liveBass = false;

drums->keybrd.setMute( false );
scaleBass = 68;

RealTimeSequencer *sqnc = (RealTimeSequencer *)drums->sqnc;
drums->keybrd.setMute( false );
sqnc->ignoreKeyUp = true;

break;
Expand Down Expand Up @@ -555,7 +588,8 @@ void Beatitude::dynamics()
* Args: ev - onboard event
*
* Memb: clickOn - if true, click track is playing
* drums->sqnc - ptr to drum kit's sequencer
* +scaleBass - scale factor for bass (128 = 50%)
* sqnc - ptr to drum kit's sequencer
*
* Rets: status - true if the event was handled
*
Expand All @@ -574,10 +608,15 @@ bool Beatitude::evHandler( obEvent ev )

case BUT1_PRESS: // record a sequence

drums->sqnc->record();
sqnc->record();
console.runModeWhile( sqnc, &this->clickOn );
break;

case POT0: // set balance between bass and drums

scaleBass = 32 + ( ev.getPotVal() >> 2 ); // range from 32 to 96
break;

case BUT0_TPRESS: // set beats and measures

if ( ! sqnc->recording() && ! sqnc->playing() )
Expand Down Expand Up @@ -747,49 +786,80 @@ void Beatitude::noteOff( key note )
* Args: bufL - ptr to left audio buffer
* bufR - ptr to right audio buffer
*
* Glob: audioBufSz - size of system audio buffers
*
* Memb: bass - ptr to bass voice
* drums - ptr to drumkit voice
* click - ptr to click track
* clickOn - if true, click track is playing
* liveBass - if true, bass is being played live
* scaleBass - scale factor for bass
*
*----------------------------------------------------------------------------*/

void Beatitude::output( char *bufL, char *bufR )
{
// create stereo panned output of drums

drums->output( bufL );

if ( clickOn )
{
click->output( bufR );
Int regX;

Int reg;
for ( byte i = 0; i < audioBufSz; i++ ) // right buf 1/2 click 1/2 drums
for ( byte i = 0; i < audioBufSz; i++ )
{
regX.val = bufL[i];
regX.val *= drums->panCoeff;
if ( drums->panRight )
{
reg.val = bufR[i] + bufL[i];
reg.val >>= 1;
bufR[i] = reg._.lsb;
bufR[i] = bufL[i];
bufL[i] = regX._.msb;
}
else
bufR[i] = regX._.msb;
}
else if ( liveBass )
{
bass->output( bufR );

Int reg;
for ( byte i = 0; i < audioBufSz; i++ ) // right buf 3/4 bass 1/4 drums
{
reg.val = bufR[i] ;
reg.val *= 3;
reg.val += bufL[i];
reg.val >>= 2;
bufR[i] = reg._.lsb;
}
// return if not recording or playing bass over drum playback

if ( (! clickOn) && (! liveBass) )
return;

// Overlay click or bass output on drums output (scaling both)

char bufOver[ audioBufSz ]; // temp buffer for click or bass output

word scaleDrums; // scale factor for drums
word scaleOver; // scale factor for overlay

if ( clickOn )
{
click->output( &bufOver[0] );
scaleOver = 64;
}
else // copy kit to right channel
else
{
for ( byte i = 0; i < audioBufSz; i++ )
bufR[i] = bufL[i];
bass->output( &bufOver[0] );
scaleOver = scaleBass;
}

scaleDrums = 256 - scaleOver;

for ( byte i = 0; i < audioBufSz; i++ )
{
char overlay; // scaled overlay value

regX.val = bufOver[i];
regX.val *= scaleOver;
overlay = regX._.msb;

regX.val = bufR[i];
regX.val *= scaleDrums;
bufR[i] = regX._.msb + overlay;

regX.val = bufL[i];
regX.val *= scaleDrums;
bufL[i] = regX._.msb + overlay;
}

}

Beatitude mySynth;
Expand Down
21 changes: 21 additions & 0 deletions Arduino/Beatitude/versions.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
Versions:

1.10 drums are panned in stereo
pot0 controls balance between bass and drums
add DrumKit::panCoeff ::panRight
add Beatitude::scaleBass
remove DEBUG sections
[31764] 1.6.6 revB
[32206] 1.8.10 revB
[32180] 1.8.10 revC
1.09 nix redundant unmuting of drums at Beatitude(sqncRECON)
1.08 add DEBUG sections
1.07 Beatitude::sqnc replaces automatic var in ::charEv()
dereferencing of "drums->sqnc->" replaced by "sqnc->"
[31566] 1.6.6
1.06 hifi Snare used for all builds
remove BUILD_166 conditional compilation sections
[31578] 1.6.6
1.05 bugfix: configVoices() was being called from Beatitude constructor!
1.04 use presetMenu + event logic to eliminate need for KEYBRD_MENUS
syncs with library 1.12
Expand All @@ -15,6 +29,13 @@ Versions:
syncs with library 1.10m
[32058 / 788] __STNDLONE__ 1.10m
1.01 corrected comments on how-to-use
[32180 / 768] __STNDLONE__ 1.10j
[32180 / 768] __STNDLONE__ 1.10g
[32182 / 770] __STNDLONE__ 1.10e
[32192 / 770] __STNDLONE__ 1.10d
[32186 / 770] __STNDLONE__ 1.10c
[32190 / 770] __STNDLONE__ 1.10b
[32174 / 768] __STNDLONE__ 1.10a
1.00 optimize DrumKit::noteOn() for size
[32194 / 768] __STNDLONE__ 1.09v
<FreeRAM 317>
Expand Down
Binary file modified Arduino/libraries/ArduTouch.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion Arduino/libraries/ArduTouch/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
The ArduTouch library and sample synths were developed using Arduino build
1.6.6. For large-scale sketches, build 1.6.6 generates smaller executables
than the current hourly build (1.8.9). If you are using build 1.6.6 you
than the current hourly build (1.8.6). If you are using build 1.6.6 you
should uncomment the following define.
------------------------------------------------------------------------ */
Expand Down
Loading

0 comments on commit 8175655

Please sign in to comment.