Skip to content

Commit

Permalink
Output sample rate is different from input.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Aug 17, 2024
1 parent 4d22ce9 commit 46fd9d2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/freedv_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ IPipelineStep* FreeDVInterface::createTransmitPipeline(int inputSampleRate, int
if (txMode_ == -1)
{
// special handling for external vocoder
parallelSteps.push_back(new ExternVocoderStep(externVocoderTxCommand_, 16000));
parallelSteps.push_back(new ExternVocoderStep(externVocoderTxCommand_, 16000, 8000));
}

for (auto& dv : dvObjects_)
Expand Down Expand Up @@ -654,7 +654,7 @@ IPipelineStep* FreeDVInterface::createReceivePipeline(
if (txMode_ == -1)
{
// special handling for external vocoder
parallelSteps.push_back(new ExternVocoderStep(externVocoderRxCommand_, 16000));
parallelSteps.push_back(new ExternVocoderStep(externVocoderRxCommand_, 8000, 16000));

state->preProcessFn = [&](ParallelStep*) { return -1; };
state->postProcessFn = [&](ParallelStep*) { return 0; };
Expand Down
5 changes: 3 additions & 2 deletions src/pipeline/ExternVocoderStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
#include "codec2_fifo.h"
#include "../defines.h"

ExternVocoderStep::ExternVocoderStep(std::string scriptPath, int workingSampleRate)
ExternVocoderStep::ExternVocoderStep(std::string scriptPath, int workingSampleRate, int outputSampleRate)
: sampleRate_(workingSampleRate)
, outputSampleRate_(outputSampleRate)
{
// Create pipes for stdin/stdout
int stdinPipes[2];
Expand Down Expand Up @@ -114,7 +115,7 @@ int ExternVocoderStep::getInputSampleRate() const

int ExternVocoderStep::getOutputSampleRate() const
{
return sampleRate_;
return outputSampleRate_;
}

std::shared_ptr<short> ExternVocoderStep::execute(std::shared_ptr<short> inputSamples, int numInputSamples, int* numOutputSamples)
Expand Down
3 changes: 2 additions & 1 deletion src/pipeline/ExternVocoderStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class ExternVocoderStep : public IPipelineStep
{
public:
ExternVocoderStep(std::string scriptPath, int workingSampleRate);
ExternVocoderStep(std::string scriptPath, int workingSampleRate, int outputSampleRate);
virtual ~ExternVocoderStep();

virtual int getInputSampleRate() const;
Expand All @@ -39,6 +39,7 @@ class ExternVocoderStep : public IPipelineStep

private:
int sampleRate_;
int outputSampleRate_;
pid_t recvProcessId_;
int receiveStdoutFd_;
int receiveStdinFd_;
Expand Down

0 comments on commit 46fd9d2

Please sign in to comment.