Difference between revisions of "Demiurge Sound Processing Engine"

From Stm32World Wiki
Jump to navigation Jump to search
Line 4: Line 4:
  
 
== Mental Model ==
 
== Mental Model ==
The mental model for the Demiurge Sound Processing Engine (DSPE) is that of
+
The mental model for the Demiurge Sound Processing Engine (DSPE) is that of blocks of computations that are wired together in the directed acyclical graph (DAG) where the wires represents audio, CV or gate/trig voltage levels.
blocks of computations that are wired together in the directed acyclical
 
graph (DAG) where the wires represents audio, CV or gate/trig voltage levels.
 
  
 
Here is an example of what that could look like, a Voltage Controlled Amplifier
 
Here is an example of what that could look like, a Voltage Controlled Amplifier
  
![Visual of Block model](blocks-vca.svg)
+
[[File:Block-vca.svg|thumb|Dual VCA block]]
  
And to code that up, we need to declare each of the ***Inputs***, ***Outputs***,
+
And to code that up, we need to declare each of the '''''Inputs''''', '''''Outputs''''','''''ControlPairs''''' and the ***Mixer***, as follows
***ControlPairs*** and the ***Mixer***, as follows
 
  
  
 
     #include "demiurge.h"
 
     #include "demiurge.h"
 +
    #include "demiurge-board.h"
 
      
 
      
     static audio_inport_t in1;      // Declaration of Audio Input Ports
+
     static audio_inport_t input1;      // Declaration of Audio Input Ports
     static audio_inport_t in2;
+
     static audio_inport_t input2;
 
      
 
      
 
     static control_pair_t pair1;    // Declaration of CV+Potentiometer Input pairs
 
     static control_pair_t pair1;    // Declaration of CV+Potentiometer Input pairs
Line 27: Line 25:
 
     static audio_outport_t out2;
 
     static audio_outport_t out2;
 
      
 
      
     static mixer_t mixer;           // Declaration of a Mixer block
+
     static scale_t scale1;
 +
    static scale_t scale2;
 
      
 
      
 
     /*
 
     /*
     * A two port Mixer, with CV control
+
     * Dual VCA.
 
     */
 
     */
     void setup() {
+
     void vca_prepare() {
         // Initialize the hardware configuration
+
         demiurge_samplerate = 50000;    // 30000 samples/second
         control_pair_init(&pair1, 1);       // CV+Pot at the top of Demiurge
+
         demiurge_set_inport_audio(1);   // set the first jack as Audio input.
         control_pair_init(&pair2, 2);      // CV+Pot at the second position from the top of Demiurge
+
         demiurge_set_inport_cv(2);      // set the second jack as Control Voltage input
         audio_inport_init(&in1, 3);         // Audio In on third input from the top
+
         demiurge_set_inport_audio(3);   // set the third jack as Audio input.
         audio_inport_init(&in2, 4);         // Audio In on fourth input from the top
+
         demiurge_set_inport_cv(4);       // set the fourth jack as Control Voltage input
        audio_outport_init(&out1, 1);      // Audio Out on left output channel
 
        audio_outport_init(&out2, 2);      // Audio Out on right output channel
 
       
 
        // Initialize Mixer with 2 channels.
 
        mixer_init(&mixer, 2);
 
       
 
        // Connect in1 on mixer channel 1, with pair1 as the volume control
 
        mixer_configure_input(&mixer, 1, &in1.me, &pair1.me);
 
 
      
 
      
         // Connect in2 on mixer channel 2, with pair2 as the volume control
+
         demiurge_set_potentiometer(2, 0.0f, 10.0f); // Potentiometers to a 0-10 range
        mixer_configure_input(&mixer, 2, &in2.me, &pair2.me);
+
         demiurge_set_potentiometer(4, 0.0f, 10.0f);
       
+
   
        // Connect mixer output to out1
+
         demiurge_set_outport_audio(1);  // Set the outputs to Audio output.
         audio_outport_configure_input(&out1, &mixer.me);
+
         demiurge_set_outport_audio(2);
       
 
         // Connect mixer output to out2
 
         audio_outport_configure_input(&out2, &mixer.me);
 
 
     }
 
     }
 
      
 
      
     void loop() {
+
     void vca_setup() {
 +
   
 +
      control_pair_init(&pair1, 2);      // CV+Pot at the second position from the top of Demiurge
 +
      control_pair_init(&pair2, 4);      // CV+Pot at the fourth position from the top of Demiurge
 +
      audio_inport_init(&input1, 1);      // Audio In on first input from the top
 +
      audio_inport_init(&input2, 3);      // Audio In on third input from the top
 +
      audio_outport_init(&out1, 1);      // Audio Out on left output channel
 +
      audio_outport_init(&out2, 2);      // Audio Out on right output channel
 +
   
 +
      scale_init(&scale1);
 +
      scale_configure(&scale1, &input1.me, &pair1.me);  //
 +
      scale1.scale = 0.1f;
 +
   
 +
      scale_init(&scale2);
 +
      scale_configure(&scale2, &input2.me, &pair2.me);
 +
      scale2.scale = 0.1f;
 +
   
 +
      // Connect scale output to out1
 +
      audio_outport_configure_input(&out1, &scale1.me);
 +
   
 +
      // Connect scale output to out2
 +
      audio_outport_configure_input(&out2, &scale2.me);
 +
    }
 +
   
 +
    void vca_loop() {
 
     }
 
     }
  
Line 75: Line 87:
 
         vca_loop();                // Give time for LEDs and Buttons
 
         vca_loop();                // Give time for LEDs and Buttons
 
     }
 
     }
 +
 +
== More Examples ==
 +
 +
All examples are in the [https://github.com/AwesomeAudioApparatus/demiurge-examples Examples Repository] and showcases many common Eurorack modules, in the most basic form.
 +
 +
=== Mute ===
 +
A Dual channel Mute.
 +
 +
=== VCA ===
 +
A Dual channel VCA.
 +
 +
=== VCO ===
 +
Dual channel Voltage Controlled Oscillator.
 +
 +
=== Envelope Generator ===
 +
A standard Envelope Generator (Attack, Decay, Sustain, Release)
 +
 +
=== LFO ===
 +
Dual channel Low Frequency Oscillator.
 +
 +
=== Quad Mixer without CV control ===
 +
 +
=== Dual Mixer with Pan control ===

Revision as of 08:27, 20 August 2022


The Demiurge Sound Processing Engine is a sound processing platform. It is designed as processing blocks that are wired together once (typically at boot) and then handles the update cycle (no buffering) automatically and without jitter.

Mental Model

The mental model for the Demiurge Sound Processing Engine (DSPE) is that of blocks of computations that are wired together in the directed acyclical graph (DAG) where the wires represents audio, CV or gate/trig voltage levels.

Here is an example of what that could look like, a Voltage Controlled Amplifier

Dual VCA block

And to code that up, we need to declare each of the Inputs, Outputs,ControlPairs and the ***Mixer***, as follows


   #include "demiurge.h"
   #include "demiurge-board.h"
   
   static audio_inport_t input1;      // Declaration of Audio Input Ports
   static audio_inport_t input2;
   
   static control_pair_t pair1;    // Declaration of CV+Potentiometer Input pairs
   static control_pair_t pair2;
   
   static audio_outport_t out1;    // Declaration of Audio Output Ports
   static audio_outport_t out2;
   
   static scale_t scale1;
   static scale_t scale2;
   
   /*
    * Dual VCA.
    */
   void vca_prepare() {
       demiurge_samplerate = 50000;     // 30000 samples/second
       demiurge_set_inport_audio(1);    // set the first jack as Audio input.
       demiurge_set_inport_cv(2);       // set the second jack as Control Voltage input
       demiurge_set_inport_audio(3);    // set the third jack as Audio input.
       demiurge_set_inport_cv(4);       // set the fourth jack as Control Voltage input
   
       demiurge_set_potentiometer(2, 0.0f, 10.0f);  // Potentiometers to a 0-10 range
       demiurge_set_potentiometer(4, 0.0f, 10.0f);
   
       demiurge_set_outport_audio(1);   // Set the outputs to Audio output.
       demiurge_set_outport_audio(2);
   }
   
   void vca_setup() {
   
      control_pair_init(&pair1, 2);       // CV+Pot at the second position from the top of Demiurge
      control_pair_init(&pair2, 4);       // CV+Pot at the fourth position from the top of Demiurge
      audio_inport_init(&input1, 1);      // Audio In on first input from the top
      audio_inport_init(&input2, 3);      // Audio In on third input from the top
      audio_outport_init(&out1, 1);       // Audio Out on left output channel
      audio_outport_init(&out2, 2);       // Audio Out on right output channel
   
      scale_init(&scale1);
      scale_configure(&scale1, &input1.me, &pair1.me);  //
      scale1.scale = 0.1f;
   
      scale_init(&scale2);
      scale_configure(&scale2, &input2.me, &pair2.me);
      scale2.scale = 0.1f;
   
      // Connect scale output to out1
      audio_outport_configure_input(&out1, &scale1.me);
   
      // Connect scale output to out2
      audio_outport_configure_input(&out2, &scale2.me);
   }
   
   void vca_loop() {
   }


The `setup()` and `loop()` functions are also custom, just to create a familiarity from the Arduino environment. In reality, this is defined in our `main.c` file, after starting the DSPE and part of the creatioin of a Demiurge project for the STM32CubeMX and optionally the STM32CubeIDE.

   vca_prepare();                  // Prepare the board for the functionality
   demiurge_driver_init();         // Initialize the hardware driver
   demiurge_init();                // Initialize the Demiurge platform
   vca_setup();                    // Set up the functionality
   demiurge_start();               // Start the audio processing
   while(1)
   {
       vca_loop();                 // Give time for LEDs and Buttons
   }

More Examples

All examples are in the Examples Repository and showcases many common Eurorack modules, in the most basic form.

Mute

A Dual channel Mute.

VCA

A Dual channel VCA.

VCO

Dual channel Voltage Controlled Oscillator.

Envelope Generator

A standard Envelope Generator (Attack, Decay, Sustain, Release)

LFO

Dual channel Low Frequency Oscillator.

Quad Mixer without CV control

Dual Mixer with Pan control