Exemplo n.º 1
0
    void PingPongDelayNode::BuildSubgraph(ContextGraphLock & lock) 
    {
        auto ac = lock.context();

        if (!ac) 
            throw std::invalid_argument("Graph lock could not acquire context");

        // Input into splitter
        input->connect(ac, splitter.get(), 0, 0);

        splitter->connect(ac, splitterGain.get(), 0, 0);
        splitter->connect(ac, splitterGain.get(), 1, 0);

        splitterGain->connect(ac, wetGain.get(), 0, 0); 
        splitterGain->gain()->setValue(0.5f);

        wetGain->connect(ac, leftDelay.get(), 0, 0);

        feedbackGain->connect(ac, leftDelay.get(), 0, 0);

        leftDelay->connect(ac, rightDelay.get(), 0, 0);
        rightDelay->connect(ac, feedbackGain.get(), 0, 0);

        leftDelay->connect(ac, merger.get(), 0, 0);
        rightDelay->connect(ac, merger.get(), 0, 1);

        merger->connect(ac, output.get(), 0, 0);

        // Activate with input->output
        input->connect(ac, output.get(), 0, 0);
    }
Exemplo n.º 2
0
void AudioNode::setChannelCountMode(ContextGraphLock& g, ChannelCountMode mode)
{
    if (mode >= ChannelCountMode::End || !g.context())
    {
        throw std::invalid_argument("No context specified");
    }
    
    else
    {
        if (m_channelCountMode != mode)
        {
            m_channelCountMode = mode;
            updateChannelsForInputs(g);
        }
    }
}
Exemplo n.º 3
0
void AudioNode::setChannelCount(ContextGraphLock& g, unsigned long channelCount)
{
    if (!g.context())
    {
        throw std::invalid_argument("No context specified");
    }
    
    if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels)
    {
        if (m_channelCount != channelCount) {
            m_channelCount = channelCount;
            if (m_channelCountMode != ChannelCountMode::Max)
                updateChannelsForInputs(g);
        }
        return;
    }
    
    throw std::logic_error("Should not be reached");
}
void DefaultAudioDestinationNode::setChannelCount(ContextGraphLock& g, unsigned long channelCount)
{
    // The channelCount for the input to this node controls the actual number of channels we
    // send to the audio hardware. It can only be set depending on the maximum number of
    // channels supported by the hardware.
    
    ASSERT(g.context());
    
    if (!maxChannelCount() || channelCount > maxChannelCount())
    {
        throw std::invalid_argument("Max channel count invalid");
    }
    
    unsigned long oldChannelCount = this->channelCount();
    AudioNode::setChannelCount(g, channelCount);
    
    if (this->channelCount() != oldChannelCount && isInitialized())
    {
        // Re-create destination.
        m_destination->stop();
        createDestination();
        m_destination->start();
    }
}