20#include <catch2/catch_amalgamated.hpp>
23TEST_CASE(
"pm::sound_compression_mp3Test",
"[yarp::pm]")
25 YARP_REQUIRE_PLUGIN(
"sound_compression_mp3",
"portmonitor")
38 TestCase {
"fast_tcp",
false},
40 TestCase {
"fast_tcp+send.portmonitor+file.sound_compression_mp3+type.dll+recv.portmonitor+file.sound_compression_mp3+type.dll",
true}
43 SECTION(
"Test sound transmission with and without MP3 compression")
49 receiver.
open(
"/recv");
55 const int frequency = 16000;
56 const size_t samples = 1600;
57 const size_t channels = 2;
61 snd.
resize(samples, channels);
71 REQUIRE(received !=
nullptr);
79 if (tc.use_compression) {
81 size_t has_non_zero = 0;
82 for (
size_t i = 0; i < samples && !has_non_zero; i++) {
83 for (
size_t c = 0; c < channels; c++) {
84 if (received->
get(i, c) != 0) {
90 CHECK(has_non_zero<50);
93 for (
size_t i = 0; i < samples; i++) {
94 for (
size_t c = 0; c < channels; c++) {
95 CHECK(received->
get(i, c) == snd.
get(i, c));
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
T * read(bool shouldWait=true) override
Read an available object from the port.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
static bool setLocalMode(bool flag)
Chooses whether communication is process-local.
Utilities for manipulating the YARP network, including initialization and shutdown.
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
void setFrequency(int freq)
Set the frequency of the sound (i.e.
size_t getChannels() const
Get the number of channels of the sound.
void resize(size_t samples, size_t channels=1)
Set the sound size.
int getFrequency() const
Get the frequency of the sound (i.e.
audio_sample get(size_t sample, size_t channel=0) const
size_t getSamples() const
Get the number of samples contained in the sound.
void delay(double seconds)
Wait for a certain number of seconds.
bool makeTone(Sound &outSound, double duration_s=1.0, size_t channels=1, size_t sampleRate=16000, double frequency=440, size_t amplitude=30000)
Generate a sound containing a sine wave tone.
The main, catch-all namespace for YARP.
TEST_CASE("pm::sound_compression_mp3Test", "[yarp::pm]")