Files
ReMixer/main.cpp
Kayleigh c0c1371823 Add WAV support
Adds WAV support building off of PCMBuffer function

also robodeath 😺
2025-04-20 20:55:16 +02:00

73 lines
2.4 KiB
C++

/// ReMixer
/// A Public Domain C++ Audio Playback Library
/// By william @ RedactedSoftware. Thanks to Dawsh & Maxine.
/// (c) 2024 Redacted Software
/// This work is explicitly dedicated to the public domain, for the hopeful betterment of the software industry.
/// @file main.cpp
/// @desc This file is the program code for the ReMixer-Test program.
/// @edit 2024-08-30
#include <iostream>
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
#include <iostream>
#include <fstream>
#include <thread>
#include <ReMixer/stream.h>
#include <ReMixer/sound.h>
#include <ReMixer/PulseSubsystem.h>
#include <ReMixer/ReMixer.h>
[[noreturn]] int main() {
using namespace ReMixer;
using namespace std::chrono_literals;
uint measurement = 44.1_kHz;
PulseAudioSubsystem server = PulseAudioSubsystem("PulseAudio Test");
server.OnServerInfo += [] (const pa_server_info* info) {
std::cout << info->host_name << " @ " << info->user_name << ", "
<< info->server_name << " v" << info->server_version << ", "
<< "default sink: " << info->default_sink_name << ", "
<< "default source" << info->default_source_name << std::endl;
};
PulseStream test_stream = server.CreateStream("Test Stream");
//PulseStream test_stream2 = test.CreateStream("Another Test Stream");
//Sound test_sound = Sound::FromPCMFile("output.raw");
Sound test_sound = Sound::FromOGGVorbisFile("../test-sounds/wind.ogg");
Sound wav_sound = Sound::FromWAVFile("../test-sounds/robodeath.wav");
Sound sine_sound = Sound::FromSineWave(5.f, 0.0025f, 3000, 0);
Sound sawtooth_sound = Sound::FromSawtoothWave(5.f, 0.025f, 2000, 0);
Sound triangle_sound = Sound::FromTriangleWave(5.f, 0.025f, 2000, 0);
Sound square_sound = Sound::FromSquareWave(5.f, 0.025f, 2000, 0);
Sound noise_sound = Sound::FromNoise(5.f, 0.01);
server.Play(test_stream, sine_sound);
server.Play(test_stream, sawtooth_sound);
server.Play(test_stream, triangle_sound);
server.Play(test_stream, square_sound);
server.Play(test_stream, noise_sound);
server.Play(test_stream, test_sound);
server.Play(test_stream, wav_sound);
while (true) {
std::this_thread::sleep_for(25ms);
}
return 0;
}
//Windows :(
#ifdef _WIN32
extern "C" {
int wmain(int argc, wchar_t* argv[]) {
return main();
}
}
#endif