Difference between revisions of "Demiurge Sound Processing Engine"

From Stm32World Wiki
Jump to navigation Jump to search
Line 29: Line 29:
 
     static mixer_t mixer;          // Declaration of a Mixer block
 
     static mixer_t mixer;          // Declaration of a Mixer block
 
      
 
      
/*
+
    /*
* A two port Mixer, with CV control
+
    * A two port Mixer, with CV control
*/
+
    */
void setup() {
+
    void setup() {
// Initialize the hardware configuration
+
        // Initialize the hardware configuration
control_pair_init(&pair1, 1);      // CV+Pot at the top of Demiurge
+
        control_pair_init(&pair1, 1);      // CV+Pot at the top of Demiurge
control_pair_init(&pair2, 2);      // CV+Pot at the second position from the top of Demiurge
+
        control_pair_init(&pair2, 2);      // CV+Pot at the second position from the top of Demiurge
audio_inport_init(&in1, 3);        // Audio In on third input from the top
+
        audio_inport_init(&in1, 3);        // Audio In on third input from the top
audio_inport_init(&in2, 4);        // Audio In on fourth input from the top
+
        audio_inport_init(&in2, 4);        // Audio In on fourth input from the top
audio_outport_init(&out1, 1);      // Audio Out on left output channel
+
        audio_outport_init(&out1, 1);      // Audio Out on left output channel
audio_outport_init(&out2, 2);      // Audio Out on right 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
 +
        mixer_configure_input(&mixer, 2, &in2.me, &pair2.me);
 +
       
 +
        // Connect mixer output to out1
 +
        audio_outport_configure_input(&out1, &mixer.me);
 +
       
 +
        // Connect mixer output to out2
 +
        audio_outport_configure_input(&out2, &mixer.me);
 +
    }
 +
   
 +
    void loop() {
 +
    }
  
// 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
 
mixer_configure_input(&mixer, 2, &in2.me, &pair2.me);
 
 
// Connect mixer output to out1
 
audio_outport_configure_input(&out1, &mixer.me);
 
 
// Connect mixer output to out2
 
audio_outport_configure_input(&out2, &mixer.me);
 
}
 
 
void loop() {
 
}
 
```
 
  
 
The `setup()` and `loop()` functions are also custom, just to create a
 
The `setup()` and `loop()` functions are also custom, just to create a
Line 66: Line 66:
 
a Demiurge project for the STM32CubeMX and optionally the STM32CubeIDE.
 
a Demiurge project for the STM32CubeMX and optionally the STM32CubeIDE.
  
```C
+
    vca_prepare();                  // Prepare the board for the functionality
  demiurge_start();
+
    demiurge_driver_init();        // Initialize the hardware driver
  setup();
+
    demiurge_init();                // Initialize the Demiurge platform
  while (1) {
+
    vca_setup();                   // Set up the functionality
      loop();
+
    demiurge_start();               // Start the audio processing
```
+
    while(1)
 +
    {
 +
        vca_loop();                 // Give time for LEDs and Buttons
 +
    }

Revision as of 09:18, 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

![Visual of Block model](blocks-vca.svg)

And to code that up, we need to declare each of the ***Inputs***, ***Outputs***,

      • ControlPairs*** and the ***Mixer***, as follows


   #include "demiurge.h"
   
   static audio_inport_t in1;      // Declaration of Audio Input Ports
   static audio_inport_t in2;
   
   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 mixer_t mixer;           // Declaration of a Mixer block
   
   /*
    * A two port Mixer, with CV control
    */
   void setup() {
       // Initialize the hardware configuration
       control_pair_init(&pair1, 1);       // CV+Pot at the top of Demiurge
       control_pair_init(&pair2, 2);       // CV+Pot at the second position from the top of Demiurge
       audio_inport_init(&in1, 3);         // Audio In on third input from the top
       audio_inport_init(&in2, 4);         // Audio In on fourth 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
       
       // 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
       mixer_configure_input(&mixer, 2, &in2.me, &pair2.me);
       
       // Connect mixer output to out1
       audio_outport_configure_input(&out1, &mixer.me);
       
       // Connect mixer output to out2
       audio_outport_configure_input(&out2, &mixer.me);
   }
   
   void 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
   }