Skip to content

InputMixer #2062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/tests/codecs/test-codec-alac/test-codec-alac.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @file test-codec-alac.ino
* @author Phil Schatzmann
* @brief generate sine wave -> encoder -> decoder -> audiokit (i2s)
* @note Activate PSRAM or dicrease the frame size e.g. by adding 1024 to the constructor of the enc_alac and dec_alac
* @version 0.1
*
* @copyright Copyright (c) 2025
Expand All @@ -11,7 +12,7 @@
#include "AudioTools/AudioCodecs/CodecALAC.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"

SET_LOOP_TASK_STACK_SIZE(16*1024); // 16KB
// SET_LOOP_TASK_STACK_SIZE(16*1024); // 16KB - not needed

AudioInfo info(44100, 2, 16);
SineWaveGenerator<int16_t> sineWave( 32000); // subclass of SoundGenerator with max amplitude of 32000
Expand Down Expand Up @@ -56,4 +57,4 @@ void setup() {

void loop() {
copier.copy();
}
}
11 changes: 5 additions & 6 deletions src/AudioTools/AudioCodecs/CodecALAC.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DecoderALAC : public AudioDecoder {
DecoderALAC(int frameSize = kALACDefaultFrameSize) {
// this is used when setCodecConfig() is not called with encoder info
setFrameSize(frameSize);
setDefaultConfig();
//setDefaultConfig();
}

// define ALACSpecificConfig
Expand Down Expand Up @@ -86,14 +86,13 @@ class DecoderALAC : public AudioDecoder {
dec.mConfig.bitDepth = from.bits_per_sample;
}


/// we expect the write is called for a complete frame!
size_t write(const uint8_t* encodedFrame, size_t encodedLen) override {
LOGD("DecoderALAC::write: %d", (int)encodedLen);
// Safety check
if (!is_init) {
LOGE("Decoder not initialized");
return 0;
}
// Make sure we have a config: we can't do this in begin because the setConfig()
// might be called after begin()
if (!is_init) setDefaultConfig();

// Make sure we have the output buffer set up
if (result_buffer.size() != outputBufferSize()) {
Expand Down
4 changes: 4 additions & 0 deletions src/AudioTools/AudioCodecs/CodecCopy.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class CopyDecoder : public AudioDecoder {

size_t write(const uint8_t *data, size_t len) {
TRACED();
if (pt_print == nullptr) {
LOGE("No output stream defined for CopyDecoder");
return 0;
}
return pt_print->write((uint8_t*)data,len);
}

Expand Down
6 changes: 4 additions & 2 deletions src/AudioTools/AudioCodecs/ContainerM4A.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ContainerM4A : public ContainerDecoder {
* @brief Set the output stream for decoded or raw audio.
* @param out_stream Output AudioStream.
*/
void setOutput(AudioStream& out_stream) override {
void setOutput(Print& out_stream) override {
if (p_decoder != nullptr) p_decoder->setOutput(out_stream);
ContainerDecoder::setOutput(out_stream);
}
Expand Down Expand Up @@ -118,7 +118,9 @@ class ContainerM4A : public ContainerDecoder {
!self->is_magic_cookie_processed) {
auto& magic_cookie = self->demux.getALACMagicCookie();
if (magic_cookie.size() > 0) {
dec.setCodecConfig(magic_cookie.data(), magic_cookie.size());
if (!dec.setCodecConfig(magic_cookie.data(), magic_cookie.size())){
LOGE("Failed to set ALAC magic cookie for decoder: %s", dec.selectedMime());
}
}
self->is_magic_cookie_processed = true;
}
Expand Down
Loading