Exemplo n.º 1
0
ScriptProcessorHandler::ScriptProcessorHandler(AudioNode& node,
                                               float sampleRate,
                                               size_t bufferSize,
                                               unsigned numberOfInputChannels,
                                               unsigned numberOfOutputChannels)
    : AudioHandler(NodeTypeJavaScript, node, sampleRate),
      m_doubleBufferIndex(0),
      m_bufferSize(bufferSize),
      m_bufferReadWriteIndex(0),
      m_numberOfInputChannels(numberOfInputChannels),
      m_numberOfOutputChannels(numberOfOutputChannels),
      m_internalInputBus(AudioBus::create(numberOfInputChannels,
                                          AudioUtilities::kRenderQuantumFrames,
                                          false)) {
  // Regardless of the allowed buffer sizes, we still need to process at the
  // granularity of the AudioNode.
  if (m_bufferSize < AudioUtilities::kRenderQuantumFrames)
    m_bufferSize = AudioUtilities::kRenderQuantumFrames;

  DCHECK_LE(numberOfInputChannels, BaseAudioContext::maxNumberOfChannels());

  addInput();
  addOutput(numberOfOutputChannels);

  m_channelCount = numberOfInputChannels;
  setInternalChannelCountMode(Explicit);

  initialize();
}
DefaultAudioDestinationHandler::DefaultAudioDestinationHandler(AudioNode& node)
    : AudioDestinationHandler(node, AudioDestination::hardwareSampleRate()),
      m_numberOfInputChannels(0) {
  // Node-specific default mixing rules.
  m_channelCount = 2;
  setInternalChannelCountMode(Explicit);
  setInternalChannelInterpretation(AudioBus::Speakers);
}
Exemplo n.º 3
0
ConvolverHandler::ConvolverHandler(AudioNode& node, float sampleRate)
    : AudioHandler(NodeTypeConvolver, node, sampleRate), m_normalize(true) {
  addInput();
  addOutput(2);

  // Node-specific default mixing rules.
  m_channelCount = 2;
  setInternalChannelCountMode(ClampedMax);
  setInternalChannelInterpretation(AudioBus::Speakers);

  initialize();
}
Exemplo n.º 4
0
ChannelMergerHandler::ChannelMergerHandler(AudioNode& node,
                                           float sampleRate,
                                           unsigned numberOfInputs)
    : AudioHandler(NodeTypeChannelMerger, node, sampleRate) {
  // These properties are fixed for the node and cannot be changed by user.
  m_channelCount = 1;
  setInternalChannelCountMode(Explicit);

  // Create the requested number of inputs.
  for (unsigned i = 0; i < numberOfInputs; ++i)
    addInput();

  // Create the output with the requested number of channels.
  addOutput(numberOfInputs);

  initialize();
}
Exemplo n.º 5
0
StereoPannerHandler::StereoPannerHandler(AudioNode& node,
                                         float sampleRate,
                                         AudioParamHandler& pan)
    : AudioHandler(NodeTypeStereoPanner, node, sampleRate),
      m_pan(pan),
      m_sampleAccuratePanValues(AudioUtilities::kRenderQuantumFrames) {
  addInput();
  addOutput(2);

  // The node-specific default mixing rules declare that StereoPannerNode
  // can handle mono to stereo and stereo to stereo conversion.
  m_channelCount = 2;
  setInternalChannelCountMode(ClampedMax);
  setInternalChannelInterpretation(AudioBus::Speakers);

  initialize();
}