Files
ReMixer/main.cpp
2024-08-06 22:36:34 -04:00

81 lines
2.0 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 StreamManager.h
/// @desc This class manages internal creation and storage of active Streams.
/// @edit 2024-08-06
#include <iostream>
#include <ReMixer/stream.h>
#include <ReMixer/sound.h>
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
#include <iostream>
#include <fstream>
void decodeVorbis(const char* inputFile, const char* outputFile)
{
OggVorbis_File vf;
FILE* inFile = fopen(inputFile, "rb");
if (!inFile) {
std::cerr << "Error opening input file." << std::endl; return;
}
if (ov_open(inFile, &vf, NULL, 0) < 0) {
std::cerr << "Error opening Ogg Vorbis file." << std::endl;
fclose(inFile);
return;
}
vorbis_info* vi = ov_info(&vf, -1);
std::ofstream outFile(outputFile, std::ios::binary);
if (!outFile.is_open()) {
std::cerr << "Error opening output file." << std::endl;
ov_clear(&vf);
fclose(inFile);
return;
}
char pcmout[4096];
int current_section;
long bytes;
while ((bytes = ov_read(&vf, pcmout, sizeof(pcmout), 0, 2, 1, &current_section)) > 0) {
outFile.write(pcmout, bytes);
}
outFile.close();
ov_clear(&vf);
fclose(inFile);
}
[[noreturn]] int main() {
const char* inputFile = "input.ogg";
const char* outputFile = "output.raw";
decodeVorbis(inputFile, outputFile);
std::cout << "Decoding complete. Raw audio data saved to " << outputFile << std::endl;
Stream stream("ReMixer-Test", "Main", SampleRate::STANDARD, StreamMode::STEREO);
bool keep_runnin = true;
while (keep_runnin) {
}
return 0;
}
//Windows :(
#ifdef _WIN32
extern "C" {
int wmain(int argc, wchar_t* argv[]) {
return main();
}
}
#endif