diff --git a/_audio_streams_converter_8h_source.html b/_audio_streams_converter_8h_source.html index 4e60bb047..6d3ff6cff 100644 --- a/_audio_streams_converter_8h_source.html +++ b/_audio_streams_converter_8h_source.html @@ -763,85 +763,87 @@
737  TRACED();
738  from_cfg = info;
739  sampleRateConverter.setAudioInfo(info);
-
740  ReformatBaseStream::setAudioInfo(info);
-
741  }
-
742 
-
743  void setAudioInfoOut(AudioInfo to) { to_cfg = to; }
+
740  numberFormatConverter.setAudioInfo(info);
+
741  channelFormatConverter.setAudioInfo(info);
+
742  ReformatBaseStream::setAudioInfo(info);
+
743  }
744 
-
745  AudioInfo audioInfoOut() override { return to_cfg; }
+
745  void setAudioInfoOut(AudioInfo to) { to_cfg = to; }
746 
-
747  bool begin(AudioInfo from, AudioInfo to) {
-
748  TRACED();
-
749  setAudioInfoOut(to);
-
750  return begin(from);
-
751  }
-
752 
-
753  bool begin(AudioInfo from) {
-
754  TRACED();
-
755  is_output_notify = false;
-
756  setAudioInfo(from);
-
757 
-
758  // build output chain
-
759  if (getStream() != nullptr) {
-
760  sampleRateConverter.setStream(*getStream());
-
761  }
-
762  if (getPrint() != nullptr) {
-
763  sampleRateConverter.setOutput(*getPrint());
-
764  }
-
765  numberFormatConverter.setStream(sampleRateConverter);
-
766  channelFormatConverter.setStream(numberFormatConverter);
-
767 
-
768  // start individual converters
-
769  bool result = channelFormatConverter.begin(from_cfg, to_cfg.channels);
-
770 
-
771  AudioInfo from_actual_cfg(from_cfg);
-
772  from_actual_cfg.channels = to_cfg.channels;
-
773  result &= numberFormatConverter.begin(from_actual_cfg.bits_per_sample,
-
774  to_cfg.bits_per_sample);
-
775 
-
776  numberFormatConverter.setBuffered(is_buffered);
-
777  sampleRateConverter.setBuffered(is_buffered);
-
778 
-
779  from_actual_cfg.bits_per_sample = to_cfg.bits_per_sample;
-
780  result &= sampleRateConverter.begin(from_actual_cfg, to_cfg.sample_rate);
-
781 
-
782  // setup reader to support readBytes()
-
783  setupReader();
-
784 
-
785  if (!result) {
-
786  LOGE("begin failed");
-
787  }
-
788  return result;
-
789  }
-
790 
-
791  virtual size_t write(const uint8_t *data, size_t len) override {
-
792  LOGD("FormatConverterStream::write: %d", (int)len);
-
793  addNotifyOnFirstWrite();
-
794  return channelFormatConverter.write(data, len);
-
795  }
-
796 
-
798  void setBuffered(bool active) { is_buffered = active; }
-
799 
-
800  float getByteFactor() {
-
801  return numberFormatConverter.getByteFactor() *
-
802  channelFormatConverter.getByteFactor();
-
803  }
-
804 
-
805  protected:
-
806  AudioInfo from_cfg;
-
807  AudioInfo to_cfg;
-
808  NumberFormatConverterStream numberFormatConverter;
-
809  ChannelFormatConverterStream channelFormatConverter;
-
810  ResampleStream sampleRateConverter;
-
811  bool is_buffered = true;
-
812 
-
815  float byteFactor() {
-
816  return (float)from_cfg.channels / (float)to_cfg.channels *
-
817  (float)from_cfg.bits_per_sample / (float)to_cfg.bits_per_sample;
-
818  }
-
819 };
-
820 
-
821 } // namespace audio_tools
+
747  AudioInfo audioInfoOut() override { return to_cfg; }
+
748 
+
749  bool begin(AudioInfo from, AudioInfo to) {
+
750  TRACED();
+
751  setAudioInfoOut(to);
+
752  return begin(from);
+
753  }
+
754 
+
755  bool begin(AudioInfo from) {
+
756  TRACED();
+
757  is_output_notify = false;
+
758  setAudioInfo(from);
+
759 
+
760  // build output chain
+
761  if (getStream() != nullptr) {
+
762  sampleRateConverter.setStream(*getStream());
+
763  }
+
764  if (getPrint() != nullptr) {
+
765  sampleRateConverter.setOutput(*getPrint());
+
766  }
+
767  numberFormatConverter.setStream(sampleRateConverter);
+
768  channelFormatConverter.setStream(numberFormatConverter);
+
769 
+
770  // start individual converters
+
771  bool result = channelFormatConverter.begin(from_cfg, to_cfg.channels);
+
772 
+
773  AudioInfo from_actual_cfg(from_cfg);
+
774  from_actual_cfg.channels = to_cfg.channels;
+
775  result &= numberFormatConverter.begin(from_actual_cfg.bits_per_sample,
+
776  to_cfg.bits_per_sample);
+
777 
+
778  numberFormatConverter.setBuffered(is_buffered);
+
779  sampleRateConverter.setBuffered(is_buffered);
+
780 
+
781  from_actual_cfg.bits_per_sample = to_cfg.bits_per_sample;
+
782  result &= sampleRateConverter.begin(from_actual_cfg, to_cfg.sample_rate);
+
783 
+
784  // setup reader to support readBytes()
+
785  setupReader();
+
786 
+
787  if (!result) {
+
788  LOGE("begin failed");
+
789  }
+
790  return result;
+
791  }
+
792 
+
793  virtual size_t write(const uint8_t *data, size_t len) override {
+
794  LOGD("FormatConverterStream::write: %d", (int)len);
+
795  addNotifyOnFirstWrite();
+
796  return channelFormatConverter.write(data, len);
+
797  }
+
798 
+
800  void setBuffered(bool active) { is_buffered = active; }
+
801 
+
802  float getByteFactor() {
+
803  return numberFormatConverter.getByteFactor() *
+
804  channelFormatConverter.getByteFactor();
+
805  }
+
806 
+
807  protected:
+
808  AudioInfo from_cfg;
+
809  AudioInfo to_cfg;
+
810  NumberFormatConverterStream numberFormatConverter;
+
811  ChannelFormatConverterStream channelFormatConverter;
+
812  ResampleStream sampleRateConverter;
+
813  bool is_buffered = true;
+
814 
+
817  float byteFactor() {
+
818  return (float)from_cfg.channels / (float)to_cfg.channels *
+
819  (float)from_cfg.bits_per_sample / (float)to_cfg.bits_per_sample;
+
820  }
+
821 };
+
822 
+
823 } // namespace audio_tools
audio_tools::AudioOutput
Abstract Audio Ouptut class.
Definition: AudioOutput.h:22
audio_tools::AudioOutput::audioInfo
virtual AudioInfo audioInfo() override
provides the actual input AudioInfo
Definition: AudioOutput.h:59
audio_tools::AudioStream
Base class for all Audio Streams. It support the boolean operator to test if the object is ready with...
Definition: BaseStream.h:109
@@ -855,9 +857,9 @@
audio_tools::ChannelFormatConverterStreamT::setAudioInfo
void setAudioInfo(AudioInfo cfg) override
Defines the input AudioInfo.
Definition: AudioStreamsConverter.h:68
audio_tools::FormatConverterStream
Converter which converts bits_per_sample, channels and the sample_rate. The conversion is supported b...
Definition: AudioStreamsConverter.h:697
audio_tools::FormatConverterStream::setOutput
void setOutput(Print &print) override
Defines/Changes the output target.
Definition: AudioStreamsConverter.h:724
-
audio_tools::FormatConverterStream::setBuffered
void setBuffered(bool active)
Buffering is active by default to minimize the number of output calls.
Definition: AudioStreamsConverter.h:798
-
audio_tools::FormatConverterStream::byteFactor
float byteFactor()
Definition: AudioStreamsConverter.h:815
-
audio_tools::FormatConverterStream::audioInfoOut
AudioInfo audioInfoOut() override
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transfo...
Definition: AudioStreamsConverter.h:745
+
audio_tools::FormatConverterStream::setBuffered
void setBuffered(bool active)
Buffering is active by default to minimize the number of output calls.
Definition: AudioStreamsConverter.h:800
+
audio_tools::FormatConverterStream::byteFactor
float byteFactor()
Definition: AudioStreamsConverter.h:817
+
audio_tools::FormatConverterStream::audioInfoOut
AudioInfo audioInfoOut() override
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transfo...
Definition: AudioStreamsConverter.h:747
audio_tools::FormatConverterStream::setAudioInfo
void setAudioInfo(AudioInfo info) override
Defines the input AudioInfo.
Definition: AudioStreamsConverter.h:736
audio_tools::FormatConverterStream::setStream
void setStream(Stream &io) override
Defines/Changes the input & output.
Definition: AudioStreamsConverter.h:712
audio_tools::NumberFormatConverterStream
Converter which converts between bits_per_sample and 16 bits. The templated NumberFormatConverterStre...
Definition: AudioStreamsConverter.h:443