// Any time a connection or disconnection happens on any of our inputs, we potentially need to change the // number of channels of our output. void ChannelMergerNode::checkNumberOfChannelsForInput(ContextRenderLock& r, AudioNodeInput* input) { // Count how many channels we have all together from all of the inputs. uint32_t numberOfOutputChannels = 0; for (uint32_t i = 0; i < numberOfInputs(); ++i) { auto input = this->input(i); if (input->isConnected()) { numberOfOutputChannels += input->bus(r)->numberOfChannels(); } } // Set the correct number of channels on the output auto output = this->output(0); output->setNumberOfChannels(r, numberOfOutputChannels); // Note * There can in rare cases be a slight delay before the output bus is updated to the new number of // channels because of tryLocks() in the context's updating system. So record the new number of // output channels here. m_desiredNumberOfOutputChannels = numberOfOutputChannels; AudioNode::checkNumberOfChannelsForInput(r, input); }
bool Radio::setSlotNumChannels(base::Number* const msg) { bool ok = false; if (msg != nullptr) { const int v = msg->getInt(); if (v >= 0 && v <= 0xFFFF) { ok = setNumberOfChannels( static_cast<unsigned short>(v) ); } } return ok; }
void DeviceAudioDX11::restartAudio (void) { #if DT2_MULTITHREADED_AUDIO AutoSpinLockRecursive lock(&_lock); #endif if (!_x_audio_2) { // Initialize Audio system HRESULT hr = XAudio2Create( &_x_audio_2, 0, XAUDIO2_DEFAULT_PROCESSOR ); Assert(SUCCEEDED(hr)); // Initialize Mastering Voice hr = _x_audio_2->CreateMasteringVoice( &_x_master_voice ); Assert(SUCCEEDED(hr)); // Initialize 3D audio XAUDIO2_VOICE_DETAILS voice_details; _x_master_voice->GetVoiceDetails(&voice_details); // Initialize 3D audio subsystem X3DAudioInitialize( voice_details.InputChannels, X3DAUDIO_SPEED_OF_SOUND, _x3_instance ); // Initialize listener ::memset(&_x3_listener,0,sizeof(X3DAUDIO_LISTENER)); // Initialize DSP parameters ::memset(&_x3_dsp,0,sizeof(X3DAUDIO_DSP_SETTINGS)); _x3_dsp_matrix.resize(voice_details.InputChannels * NUM_CHANNELS); _x3_dsp_delays.resize(voice_details.InputChannels); _x3_dsp.pMatrixCoefficients = &_x3_dsp_matrix[0]; _x3_dsp.pDelayTimes = &_x3_dsp_delays[0]; _x3_dsp.DstChannelCount = voice_details.InputChannels; _x3_dsp.SrcChannelCount = 0; // Changed on the fly when calculating // Initialize rest of this class setNumberOfChannels(32); // Get all channels playing again for (DTuint c = 0; c < min2(_channels.size(),_save_channels.size()); ++c) { playOnChannel (_channels[c], _save_channels[c]._source, _save_channels[c]._sound_loader); RELEASE(_save_channels[c]._source); RELEASE(_save_channels[c]._sound_loader); } _save_channels.clear(); } }
void TacanRadio::initData() { setMaxDetectRange(120.0); setNumberOfChannels(126); rangeIsValid = false; bearingIsValid = false; range = 0; grdrange = 0; bearing = 0; destLatitude = 0; destLongitude = 0; currentMagVar = 0; band = TCN_X_BAND; // Set frequencies { unsigned short chan = 1; // channels [ 1 .. 16 ] while (chan <= 16) { setChannelFrequency(chan++, 0.0f); } // channels [ 17 .. 59 ] while (chan < 59) { setChannelFrequency(chan, (LCreal(chan) * 0.1f + 106.3f)); chan++; } // channels [ 60 .. 69 ] while (chan <= 69) { setChannelFrequency(chan++, 0.0f); } // channels [ 70 .. 126 ] while (chan <= 126) { setChannelFrequency(chan, (LCreal(chan) * 0.1f + 107.3f) ); chan++; } } }
//------------------------------------------------------------------------------ // copyData() -- copy member data //------------------------------------------------------------------------------ void Radio::copyData(const Radio& org, const bool cc) { BaseClass::copyData(org); if (cc) initData(); // (Re)set the number of channels setNumberOfChannels(org.numChan); // Copy the channel frequencies unsigned short numChannels = getNumberOfChannels(); for (unsigned short chan = 1; chan <= numChannels; chan++) { setChannelFrequency( chan, org.getChannelFrequency(chan) ); } // Set the channel number setChannel(org.channel); radioId = org.radioId; maxDetectRange = org.maxDetectRange; }
DynamicsCompressorKernel::DynamicsCompressorKernel(float sampleRate, unsigned numberOfChannels) : m_sampleRate(sampleRate) , m_lastPreDelayFrames(DefaultPreDelayFrames) , m_preDelayReadIndex(0) , m_preDelayWriteIndex(DefaultPreDelayFrames) , m_ratio(uninitializedValue) , m_slope(uninitializedValue) , m_linearThreshold(uninitializedValue) , m_dbThreshold(uninitializedValue) , m_dbKnee(uninitializedValue) , m_kneeThreshold(uninitializedValue) , m_kneeThresholdDb(uninitializedValue) , m_ykneeThresholdDb(uninitializedValue) , m_K(uninitializedValue) { setNumberOfChannels(numberOfChannels); // Initializes most member variables reset(); m_meteringReleaseK = static_cast<float>(WebAudioUtils::DiscreteTimeConstantForSampleRate(meteringReleaseTimeConstant, sampleRate)); }
//------------------------------------------------------------------------------ // deleteData() -- delete member data //------------------------------------------------------------------------------ void Radio::deleteData() { setNumberOfChannels(0); }