-
Notifications
You must be signed in to change notification settings - Fork 0
/
AudioPlugs.cpp
53 lines (43 loc) · 998 Bytes
/
AudioPlugs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* AudioInputPlugs for switching one of the inputs through to the single output. Also
* all inputs can be disabled.
*
* AudioOutputPlugs for switching the single input through to the active outputs,
* which may be more than one.
*
* Developed 2018 by Koen van Dijken
*/
#include <Arduino.h>
#include "audioplugs.h"
/**
*/
void AudioInputPlugs::update(void)
{
if ( activeChannel != -1 ) {
audio_block_t *in = receiveReadOnly( activeChannel );
if ( in ) {
transmit( in );
release( in );
}
}
}
/**
*/
void AudioOutputPlugs::update( void )
{
audio_block_t *block = NULL;
// Copy the input stream to all active output streams.
for ( int channel = 0; channel < 4; channel++ ) {
if (!(activemask & (1 << channel)))
continue;
if ( block == NULL ) {
// Ask for the input stream
block = receiveReadOnly( 0 );
if ( !block )
return;
}
transmit( block, channel );
}
if ( block )
release( block );
}