BaseMachine Sequencer

Dependencies:   Amp AverageAnalogIn BaseMachineUIController Envelope ExioBufferdController FilterController MCP23S17 PinDetect RotaryEncoder Sequence SequencerDisplay mbed-rtos mbed st7567LCD AT24C1024 OscController

Files at this revision

API Documentation at this revision

Comitter:
ryood
Date:
Mon May 22 23:00:08 2017 +0000
Branch:
FilterEnvelope
Parent:
28:407c9f46a07c
Commit message:
Impl. FilterEnvelope

Changed in this revision

BaseMachineCommon.h Show annotated file Show diff for this revision Revisions of this file
Envelope.lib Show annotated file Show diff for this revision Revisions of this file
FilterController.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 407c9f46a07c -r 5ca5aef9e7ca BaseMachineCommon.h
--- a/BaseMachineCommon.h	Mon May 22 14:26:31 2017 +0000
+++ b/BaseMachineCommon.h	Mon May 22 23:00:08 2017 +0000
@@ -8,11 +8,11 @@
 #ifndef _BASEMACHINE_COMMON_H_
 #define _BASEMACHINE_COMMON_H_
 
-#define USE_VCVS    1
-//#define USE_SVF   1
+//#define USE_VCVS    1
+#define USE_SVF   1
 
 #define TITLE_STR1  ("BaseMachine Test")
-#define TITLE_STR2  ("2017.05.04")
+#define TITLE_STR2  ("2017.05.23")
 
 #if USE_VCVS
     #define TITLE_STR3  ("VCVS LPF Version")
diff -r 407c9f46a07c -r 5ca5aef9e7ca Envelope.lib
--- a/Envelope.lib	Mon May 22 14:26:31 2017 +0000
+++ b/Envelope.lib	Mon May 22 23:00:08 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/ryood/code/Envelope/#f1094f102701
+https://developer.mbed.org/users/ryood/code/Envelope/#e2e50902edee
diff -r 407c9f46a07c -r 5ca5aef9e7ca FilterController.lib
--- a/FilterController.lib	Mon May 22 14:26:31 2017 +0000
+++ b/FilterController.lib	Mon May 22 23:00:08 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/ryood/code/FilterController/#01a7e00317be
+https://developer.mbed.org/users/ryood/code/FilterController/#5be9dcebbd62
diff -r 407c9f46a07c -r 5ca5aef9e7ca main.cpp
--- a/main.cpp	Mon May 22 14:26:31 2017 +0000
+++ b/main.cpp	Mon May 22 23:00:08 2017 +0000
@@ -49,7 +49,7 @@
 
 #if USE_VCVS
     SpiVcvsLpfController FilterController(&SpiMaster, D10);
-#else if USE_SVF
+#elif USE_SVF
     SpiSvfController FilterController(&SpiMaster, D10);
 #endif
 
@@ -67,26 +67,38 @@
 //------------------------------------------------------------------------
 void updateTicks(int ticks)
 {
+    uint16_t level = EnvelopeGenerator.update(sequences[SequenceSender.getStep()].isTie());
+    
+    // Amp
+    uint16_t ampLevel = level;
     if (sequences[SequenceSender.getStep()].isNoteOn())
     {
-        uint16_t level = EnvelopeGenerator.update(sequences[SequenceSender.getStep()].isTie());
-        level = level >> 1;
+        ampLevel = ampLevel >> 1;
         if (sequences[SequenceSender.getStep()].isAccent())
         {
-            // Todo: 小数点演算を整数に
-            level *= 1.0f + ((float)UIController.getAccentLevel()) / 128.0f;
+            ampLevel = ampLevel * (1.0f + ((float)UIController.getAccentLevel()) / 128.0f);
         }
-        AmpController.outDca(level);
     }
     else
     {
-        AmpController.outDca(0);
+        ampLevel = 0;
     }
+    AmpController.outDca(ampLevel);
     
+    // Oscillator
     OscController.setFrequency10(SequenceSender.getFrequency10());
     OscController.outDco();
     
-    FilterController.outDcf();
+    // Filter Env Mod
+    uint16_t cutoff16 = FilterController.getCutoff();
+    uint8_t resonance = FilterController.getResonance();
+    uint8_t mod = FilterController.getModLevel();
+    float modCoeff = (float)mod / (float)(cutoff16 << 1);
+    cutoff16 = cutoff16 * (1.0f + ((float)level / 0x8000) * modCoeff);
+    if (cutoff16 > 255) {
+        cutoff16 = 255;
+    }
+    FilterController.outDcf(cutoff16, resonance);
     
     if (ticks == 0)
     {
@@ -117,7 +129,8 @@
 
     EnvelopeParam env;
     UIController.getEnvelopeParam(&env);
-    envelope.setLevel(env.level << 5);
+    //envelope.setLevel(env.level << 5);
+    FilterController.setModLevel(env.level << 1);
     //ToDo: Impl. envelope length
     envelope.setLength(envelopeLength);
     envelope.setDuration((float)env.duration / 128.0f * envelopeLength);