| 38 | }; |
| 39 | |
| 40 | void MultichannelOutputApp::setup() |
| 41 | { |
| 42 | mCurrentChannel = 0; |
| 43 | |
| 44 | setupMultichannelDevice(); |
| 45 | |
| 46 | auto ctx = audio::Context::master(); |
| 47 | |
| 48 | // for information on creating Node's, see NodeBasic sample. |
| 49 | mGen = ctx->makeNode( new audio::GenSineNode( 440, audio::Node::Format().autoEnable() ) ); |
| 50 | mGain = ctx->makeNode( new audio::GainNode( 0 ) ); |
| 51 | |
| 52 | // make a ChannelRouterNode with the same number of channels as the Context's output, which is the multichannel output device. |
| 53 | mChannelRouterNode = ctx->makeNode( new audio::ChannelRouterNode( audio::Node::Format().channels( ctx->getOutput()->getNumChannels() ) ) ); |
| 54 | |
| 55 | // make a Scope to visualize the channels. You don't need to specify the number of channels here because its default ChannelMode is MATCHES_INPUT. |
| 56 | mMonitor = ctx->makeNode( new audio::MonitorNode ); |
| 57 | |
| 58 | // connect up our Node's, routing mGain to the output channel specified by mCurrentChannel. Send the result through the Scope, onto the output. |
| 59 | mGen >> mGain >> mChannelRouterNode->route( 0, mCurrentChannel ) >> mMonitor >> ctx->getOutput(); |
| 60 | |
| 61 | ctx->enable(); |
| 62 | |
| 63 | // Start the gain ramping. When this finishes, the route channel will be shifted and a new gain ramp will be applied. |
| 64 | rampGain(); |
| 65 | } |
| 66 | |
| 67 | void MultichannelOutputApp::setupMultichannelDevice() |
| 68 | { |