Skip to content

Commit

Permalink
AudioSwitchMatrix_F32.h: Improve comments and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
chipaudette authored Oct 2, 2024
1 parent b1dfb37 commit 9085fc4
Showing 1 changed file with 43 additions and 47 deletions.
90 changes: 43 additions & 47 deletions src/AudioSwitchMatrix_F32.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/*
* AudioSwitchMatrix
*
* AudioSwitch4
* AudioSwitchMatrix4_F32 (or AudioSwitchmatrix8_F32)
*
* Created: Chip Audette, OpenAudio, Sept 2024
* Purpose: Switch 4 inputs among 4 outputs
* Assumes floating-point data.
* Purpose: Switch 4 inputs among 4 outputs (or 8 and 8)
*
* MIT License. use at your own risk.
*/
Expand All @@ -15,27 +13,25 @@
#include "AudioStream_F32.h"

class AudioSwitchMatrix4_F32 : public AudioStream_F32 {
//GUI: inputs:4, outputs:4 //this line used for automatic generation of GUI node
//GUI: shortName:SwitchMtrx4
public:
AudioSwitchMatrix4_F32() : AudioStream_F32(4, inputQueueArray) { setDefaultValues(); }
AudioSwitchMatrix4_F32(const AudioSettings_F32 &settings) : AudioStream_F32(4, inputQueueArray) { setDefaultValues(); }

void setDefaultValues(void) {
for (int i=0; i < max_n_chan; i++) setInputToOutput(i,i); //default to straight through...output 0 uses input 0, output 1 uses input 1, etc
}

virtual void update(void);
//GUI: inputs:4, outputs:4 //this line used for automatic generation of GUI node
//GUI: shortName:SwitchMtrx4
public:
AudioSwitchMatrix4_F32() : AudioStream_F32(4, inputQueueArray) { setDefaultValues(); }
AudioSwitchMatrix4_F32(const AudioSettings_F32 &settings) : AudioStream_F32(4, inputQueueArray) { setDefaultValues(); }
void setDefaultValues(void) {
for (int i=0; i < max_n_chan; i++) setInputToOutput(i,i); //default to straight through...output 0 uses input 0, output 1 uses input 1, etc
}
virtual void update(void);

// Set output_chan to negative value to mute the input. One input can be used multiple times,
// but if you try to use the same output multiple times, only the latest-to-be-specified will
// be used.
int setInputToOutput(int input_chan, int output_chan) {
if ((output_chan >= 0) && (output_chan < max_n_chan)) {
return inputForEachOutput[output_chan] = input_chan;
// Set output_chan to negative value to mute the input. One input can be used multiple times,
// but if you try to use the same output multiple times, only the latest-to-be-specified will
// be used.
int setInputToOutput(int input_chan, int output_chan) {
if ((output_chan >= 0) && (output_chan < max_n_chan)) {
return inputForEachOutput[output_chan] = input_chan;
}
return -1;
}
return -1;
}

private:
const int max_n_chan = 4;
Expand All @@ -44,32 +40,32 @@ class AudioSwitchMatrix4_F32 : public AudioStream_F32 {
};

class AudioSwitchMatrix8_F32 : public AudioStream_F32 {
//GUI: inputs:8, outputs:8 //this line used for automatic generation of GUI node
//GUI: shortName:SwitchMtrx8
public:
AudioSwitchMatrix8_F32() : AudioStream_F32(8, inputQueueArray) { setDefaultValues(); }
AudioSwitchMatrix8_F32(const AudioSettings_F32 &settings) : AudioStream_F32(8, inputQueueArray) { setDefaultValues(); }

void setDefaultValues(void) {
for (int i=0; i < max_n_chan; i++) setInputToOutput(i,i); //default to straight through...output 0 uses input 0, output 1 uses input 1, etc
}

virtual void update(void);
//GUI: inputs:8, outputs:8 //this line used for automatic generation of GUI node
//GUI: shortName:SwitchMtrx8
public:
AudioSwitchMatrix8_F32() : AudioStream_F32(8, inputQueueArray) { setDefaultValues(); }
AudioSwitchMatrix8_F32(const AudioSettings_F32 &settings) : AudioStream_F32(8, inputQueueArray) { setDefaultValues(); }

void setDefaultValues(void) {
for (int i=0; i < max_n_chan; i++) setInputToOutput(i,i); //default to straight through...output 0 uses input 0, output 1 uses input 1, etc
}

// Set output_chan to negative value to mute the input. One input can be used multiple times,
// but if you try to use the same output multiple times, only the latest-to-be-specified will
// be used.
int setInputToOutput(int input_chan, int output_chan) {
if ((output_chan >= 0) && (output_chan < max_n_chan)) {
return inputForEachOutput[output_chan] = input_chan;
virtual void update(void);

// Set output_chan to negative value to mute the input. One input can be used multiple times,
// but if you try to use the same output multiple times, only the latest-to-be-specified will
// be used.
int setInputToOutput(int input_chan, int output_chan) {
if ((output_chan >= 0) && (output_chan < max_n_chan)) {
return inputForEachOutput[output_chan] = input_chan;
}
return -1;
}
return -1;
}

private:
private:
const int max_n_chan = 8;
audio_block_f32_t *inputQueueArray[8];
int inputForEachOutput[8]; //inputForEachOutput[0] is the input for output[0], inputForEachOutput[1] is the input for output[1], etc
audio_block_f32_t *inputQueueArray[8];
int inputForEachOutput[8]; //inputForEachOutput[0] is the input for output[0], inputForEachOutput[1] is the input for output[1], etc
};

#endif
#endif

0 comments on commit 9085fc4

Please sign in to comment.