Skip to content

Commit

Permalink
minor example updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiakopoulos committed Dec 13, 2018
1 parent b00efee commit 09c1511
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015, Dimitri Diakopoulos All rights reserved.
Copyright (c) 2019, Dimitri Diakopoulos All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
24 changes: 14 additions & 10 deletions examples/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,7 @@ int main(int argc, const char **argv) try
std::cout << "[Warning - Sample Rate Mismatch] - file is sampled at " << fileData->sampleRate << " and output is " << desiredSampleRate << std::endl;
}

// Resample
std::vector<float> outputBuffer;
outputBuffer.reserve(fileData->samples.size());
linear_resample(44100.0 / 48000.0, fileData->samples, outputBuffer, (uint32_t) fileData->samples.size());

std::cout << "Input Samples: " << fileData->samples.size() << std::endl;
std::cout << "Output Samples: " << outputBuffer.size() << std::endl;

// Convert mono to stereo for testing playback
if (fileData->channelCount == 1)
Expand All @@ -132,13 +126,23 @@ int main(int argc, const char **argv) try
}
else
{
std::cout << "Playing for: " << fileData->lengthSeconds << " seconds..." << std::endl;
std::cout << "Playing STEREO for: " << fileData->lengthSeconds << " seconds..." << std::endl;
myDevice.Play(fileData->samples);
}

fileData->samples = outputBuffer;
int encoderStatus = encode_opus_to_disk({ 1, PCM_FLT, DITHER_NONE }, fileData.get(), "encoded.opus");
std::cout << "Encoder Status: " << encoderStatus << std::endl;
// Test Opus Encoding
{
// Resample
std::vector<float> outputBuffer;
std::cout << "Output Samples: " << outputBuffer.size() << std::endl;

outputBuffer.reserve(fileData->samples.size() * 2);
linear_resample(fileData->sampleRate / 48000.0f, fileData->samples, outputBuffer, (uint32_t)fileData->samples.size());

fileData->samples = outputBuffer;
int encoderStatus = encode_opus_to_disk({ fileData->channelCount, PCM_FLT, DITHER_NONE }, fileData.get(), "libnyquist_example_output.opus");
std::cout << "Encoder Status: " << encoderStatus << std::endl;
}

return EXIT_SUCCESS;
}
Expand Down

0 comments on commit 09c1511

Please sign in to comment.