<commit_before>#include <spdlog/spdlog.h>

#include <iostream>
#include "core/audio/codecs/vorbis.hpp"
#include "core/audio/streams/resample.hpp"
#include "core/audio/output/soundio.hpp"

#include <chrono>
#include <thread>

#define OggTestFile "TestOgg.ogg"


int main(int argc, char const *argv[]) {
    std::shared_ptr<spdlog::logger> logger;

    try {
        std::vector<spdlog::sink_ptr> sinks;
        // I would like to use the sink that does color output to the console
        // but it doesnt yet work for windows.
        sinks.push_back(std::make_shared<spdlog::sinks::stdout_sink_mt>());
        // Probably will want to switch this to ostream_sink_mt once
        // the vfs is setup fully.
        sinks.push_back(std::make_shared<spdlog::sinks::simple_file_sink_mt>("openrhythmaudio.log"));

        logger = std::make_shared<spdlog::logger>("default", std::begin(sinks), std::end(sinks));
        spdlog::register_logger(logger);

        // Should be set by the configuration eventually.
        logger->set_level(spdlog::level::debug);

    } catch (const spdlog::spdlog_ex& err) {
        std::cout << "Logging Failed: " << err.what() << std::endl;
        return 1;
    }


    // We should use a smart pointer raw new/delete is considered bad style nowdays.
    ORCore::VorbisInput *mysong;
    try {
        mysong = new ORCore::VorbisInput(OggTestFile);
        mysong->open();
    } catch (const std::runtime_error& err) {
        std::cout << "opening ogg vorbis file failed: " << err.what() << std::endl;
    }

    int songSampleRate = mysong->getSampleRate();
    int outputSampleRate = 44100;

    logger->info("SongSampleRate: {}", songSampleRate);


    auto soundOutput = new ORCore::SoundIoOutput();
    soundOutput->connect_default_output_device();
    soundOutput->open_stream_with_sample_rate(outputSampleRate);

    auto *resamplerstream =
        new ORCore::ResamplerStream(mysong, SRC_SINC_MEDIUM_QUALITY);
    resamplerstream->setInputSampleRate(songSampleRate);
    resamplerstream->setOutputSampleRate(outputSampleRate);


    logger->debug("addstream resamplerstream");
    soundOutput->add_stream(resamplerstream);
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));
    soundOutput->destroy();
    soundOutput->disconnect_device();

    std::this_thread::sleep_for(std::chrono::milliseconds(1000));

}<commit_msg>Add a test for multiple audio streams output<commit_after>#include <spdlog/spdlog.h>

#include <iostream>
#include "core/audio/codecs/vorbis.hpp"
#include "core/audio/streams/resample.hpp"
#include "core/audio/output/soundio.hpp"

#include <chrono>
#include <thread>

#define OggTestFile "TestOgg.ogg"
#define OggAnotherFile "/usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga"


int main(int argc, char const *argv[]) {
    std::shared_ptr<spdlog::logger> logger;

    try {
        std::vector<spdlog::sink_ptr> sinks;
        // I would like to use the sink that does color output to the console
        // but it doesnt yet work for windows.
        sinks.push_back(std::make_shared<spdlog::sinks::stdout_sink_mt>());
        // Probably will want to switch this to ostream_sink_mt once
        // the vfs is setup fully.
        sinks.push_back(std::make_shared<spdlog::sinks::simple_file_sink_mt>("openrhythmaudio.log"));

        logger = std::make_shared<spdlog::logger>("default", std::begin(sinks), std::end(sinks));
        spdlog::register_logger(logger);

        // Should be set by the configuration eventually.
        logger->set_level(spdlog::level::debug);

    } catch (const spdlog::spdlog_ex& err) {
        std::cout << "Logging Failed: " << err.what() << std::endl;
        return 1;
    }

    int outputSampleRate = 44100;

    // We should use a smart pointer raw new/delete is considered bad style nowdays.
    ORCore::VorbisInput *mysong;
    try {
        mysong = new ORCore::VorbisInput(OggTestFile);
        mysong->open();
    } catch (const std::runtime_error& err) {
        std::cout << "opening ogg vorbis file failed: " << err.what() << std::endl;
    }

    int songSampleRate = mysong->getSampleRate();

    auto *resamplerstream =
        new ORCore::ResamplerStream(mysong, SRC_SINC_MEDIUM_QUALITY);
    resamplerstream->setInputSampleRate(songSampleRate);
    resamplerstream->setOutputSampleRate(outputSampleRate);


    logger->info("SongSampleRate: {}", songSampleRate);


    // Add another sound to test multiple streams output
    ORCore::VorbisInput *anotherOgg;
    try {
        anotherOgg = new ORCore::VorbisInput(OggAnotherFile);
        anotherOgg->open();
    } catch (const std::runtime_error& err) {
        std::cout << "opening ogg vorbis file failed: " << err.what() << std::endl;
    }

    int anotherOggSampleRate = mysong->getSampleRate();

    auto *anotherResamplerstream =
        new ORCore::ResamplerStream(anotherOgg, SRC_SINC_MEDIUM_QUALITY);
    anotherResamplerstream->setInputSampleRate(anotherOggSampleRate);
    anotherResamplerstream->setOutputSampleRate(outputSampleRate);



    auto soundOutput = new ORCore::SoundIoOutput();
    soundOutput->connect_default_output_device();
    soundOutput->open_stream_with_sample_rate(outputSampleRate);



    logger->debug("addstream resamplerstream");
    soundOutput->add_stream(resamplerstream);
    soundOutput->add_stream(anotherResamplerstream);
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));
    soundOutput->destroy();
    soundOutput->disconnect_device();

    std::this_thread::sleep_for(std::chrono::milliseconds(1000));

}
{'fraction_non_alphanumeric': 0.12911346880057545, 'fraction_numerical': 0.005035065635677036, 'mean_word_length': 3.9794091316025066, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6241035', 'n_tokens_mistral': 1843, 'n_tokens_neox': 1761, 'n_words': 346}