Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile.mingw
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CFLAGS=-std=c99 -pedantic -Wall -O
CXXFLAGS=-static -pedantic -Wall -Weffc++ -Wextra -Wold-style-cast -O
STRIP=i586-mingw32msvc-strip
CC=i586-mingw32msvc-gcc
CXX=i586-mingw32msvc-g++
STRIP=i686-w64-mingw32-strip
CC=i686-w64-mingw32-gcc
CXX=i686-w64-mingw32-g++
EXE_EXT=.exe

include Makefile.common
51 changes: 36 additions & 15 deletions src/ww2ogg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include "wwriff.h"
#include "stdint.h"
#include "errors.h"
#ifdef __MINGW32__
#include <fcntl.h>
#endif

using namespace std;

Expand All @@ -16,13 +19,15 @@ class ww2ogg_options
bool inline_codebooks;
bool full_setup;
ForcePacketFormat force_packet_format;
bool to_stdout;
public:
ww2ogg_options(void) : in_filename(""),
out_filename(""),
codebooks_filename("packed_codebooks.bin"),
inline_codebooks(false),
full_setup(false),
force_packet_format(kNoForcePacketFormat)
force_packet_format(kNoForcePacketFormat),
to_stdout(false)
{}
void parse_args(int argc, char **argv);
const string& get_in_filename(void) const {return in_filename;}
Expand All @@ -31,19 +36,20 @@ class ww2ogg_options
bool get_inline_codebooks(void) const {return inline_codebooks;}
bool get_full_setup(void) const {return full_setup;}
ForcePacketFormat get_force_packet_format(void) const {return force_packet_format;}
bool get_to_stdout(void) const {return to_stdout;}
};

void usage(void)
{
cout << endl;
cout << "usage: ww2ogg input.wav [-o output.ogg] [--inline-codebooks] [--full-setup]" << endl <<
cerr << endl;
cerr << "usage: ww2ogg input.wav [-o output.ogg] [--inline-codebooks] [--full-setup]" << endl <<
" [--mod-packets | --no-mod-packets]" << endl <<
" [--pcb packed_codebooks.bin]" << endl << endl;
" [--pcb packed_codebooks.bin] [--stdout]" << endl << endl;
}

int main(int argc, char **argv)
{
cout << "Audiokinetic Wwise RIFF/RIFX Vorbis to Ogg Vorbis converter " VERSION " by hcs" << endl << endl;
cerr << "Audiokinetic Wwise RIFF/RIFX Vorbis to Ogg Vorbis converter " VERSION " by hcs" << endl << endl;

ww2ogg_options opt;

Expand All @@ -53,15 +59,15 @@ int main(int argc, char **argv)
}
catch (const Argument_error& ae)
{
cout << ae << endl;
cerr << ae << endl;

usage();
return 1;
}

try
{
cout << "Input: " << opt.get_in_filename() << endl;
cerr << "Input: " << opt.get_in_filename() << endl;
Wwise_RIFF_Vorbis ww(opt.get_in_filename(),
opt.get_codebooks_filename(),
opt.get_inline_codebooks(),
Expand All @@ -70,22 +76,32 @@ int main(int argc, char **argv)
);

ww.print_info();
cout << "Output: " << opt.get_out_filename() << endl;

ofstream of(opt.get_out_filename().c_str(), ios::binary);
if (!of) throw File_open_error(opt.get_out_filename());

ww.generate_ogg(of);
cout << "Done!" << endl << endl;
if (!opt.get_to_stdout())
{
cerr << "Output: " << opt.get_out_filename() << endl;
ofstream of(opt.get_out_filename().c_str(), ios::binary);
if (!of) throw File_open_error(opt.get_out_filename());
ww.generate_ogg(of);
}
else
{
#ifdef __MINGW32__
_setmode( _fileno( stdout ), _O_BINARY );
#endif
ww.generate_ogg(cout);
}
cerr << "Output: stdout" << endl;
cerr << "Done!" << endl << endl;
}
catch (const File_open_error& fe)
{
cout << fe << endl;
cerr << fe << endl;
return 1;
}
catch (const Parse_error& pe)
{
cout << pe << endl;
cerr << pe << endl;
return 1;
}

Expand Down Expand Up @@ -150,6 +166,11 @@ void ww2ogg_options::parse_args(int argc, char ** argv)

codebooks_filename = argv[++i];
}
else if (!strcmp(argv[i], "--stdout"))
{
// write to stdout
to_stdout = true;
}
else
{
// assume anything else is an input file name
Expand Down
48 changes: 24 additions & 24 deletions src/wwriff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,73 +459,73 @@ void Wwise_RIFF_Vorbis::print_info(void)
{
if (_little_endian)
{
cout << "RIFF WAVE";
cerr << "RIFF WAVE";
}
else
{
cout << "RIFX WAVE";
cerr << "RIFX WAVE";
}
cout << " " << _channels << " channel";
if (_channels != 1) cout << "s";
cout << " " << _sample_rate << " Hz " << _avg_bytes_per_second*8 << " bps" << endl;
cout << _sample_count << " samples" << endl;
cerr << " " << _channels << " channel";
if (_channels != 1) cerr << "s";
cerr << " " << _sample_rate << " Hz " << _avg_bytes_per_second*8 << " bps" << endl;
cerr << _sample_count << " samples" << endl;

if (0 != _loop_count)
{
cout << "loop from " << _loop_start << " to " << _loop_end << endl;
cerr << "loop from " << _loop_start << " to " << _loop_end << endl;
}

if (_old_packet_headers)
{
cout << "- 8 byte (old) packet headers" << endl;
cerr << "- 8 byte (old) packet headers" << endl;
}
else if (_no_granule)
{
cout << "- 2 byte packet headers, no granule" << endl;
cerr << "- 2 byte packet headers, no granule" << endl;
}
else
{
cout << "- 6 byte packet headers" << endl;
cerr << "- 6 byte packet headers" << endl;
}

if (_header_triad_present)
{
cout << "- Vorbis header triad present" << endl;
cerr << "- Vorbis header triad present" << endl;
}

if (_full_setup || _header_triad_present)
{
cout << "- full setup header" << endl;
cerr << "- full setup header" << endl;
}
else
{
cout << "- stripped setup header" << endl;
cerr << "- stripped setup header" << endl;
}

if (_inline_codebooks || _header_triad_present)
{
cout << "- inline codebooks" << endl;
cerr << "- inline codebooks" << endl;
}
else
{
cout << "- external codebooks (" << _codebooks_name << ")" << endl;
cerr << "- external codebooks (" << _codebooks_name << ")" << endl;
}

if (_mod_packets)
{
cout << "- modified Vorbis packets" << endl;
cerr << "- modified Vorbis packets" << endl;
}
else
{
cout << "- standard Vorbis packets" << endl;
cerr << "- standard Vorbis packets" << endl;
}

#if 0
if (0 != _cue_count)
{
cout << _cue_count << " cue point";
if (_cue_count != 1) cout << "s";
cout << endl;
cerr << _cue_count << " cue point";
if (_cue_count != 1) cerr << "s";
cerr << endl;
}
#endif
}
Expand Down Expand Up @@ -646,7 +646,7 @@ void Wwise_RIFF_Vorbis::generate_ogg_header(Bit_oggstream& os, bool * & mode_blo
unsigned int codebook_count = codebook_count_less1 + 1;
os << codebook_count_less1;

//cout << codebook_count << " codebooks" << endl;
//cerr << codebook_count << " codebooks" << endl;

// rebuild codebooks
if (_inline_codebooks)
Expand Down Expand Up @@ -675,7 +675,7 @@ void Wwise_RIFF_Vorbis::generate_ogg_header(Bit_oggstream& os, bool * & mode_blo
{
Bit_uint<10> codebook_id;
ss >> codebook_id;
//cout << "Codebook " << i << " = " << codebook_id << endl;
//cerr << "Codebook " << i << " = " << codebook_id << endl;
try
{
cbl.rebuild(codebook_id, os);
Expand Down Expand Up @@ -983,7 +983,7 @@ void Wwise_RIFF_Vorbis::generate_ogg_header(Bit_oggstream& os, bool * & mode_blo
mode_blockflag = new bool [mode_count];
mode_bits = ilog(mode_count-1);

//cout << mode_count << " modes" << endl;
//cerr << mode_count << " modes" << endl;

for (unsigned int i = 0; i < mode_count; i++)
{
Expand Down Expand Up @@ -1017,7 +1017,7 @@ void Wwise_RIFF_Vorbis::generate_ogg_header(Bit_oggstream& os, bool * & mode_blo
}
}

void Wwise_RIFF_Vorbis::generate_ogg(ofstream& of)
void Wwise_RIFF_Vorbis::generate_ogg(ostream& of)
{
Bit_oggstream os(of);

Expand Down
2 changes: 1 addition & 1 deletion src/wwriff.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Wwise_RIFF_Vorbis

void print_info(void);

void generate_ogg(ofstream& of);
void generate_ogg(ostream& of);
void generate_ogg_header(Bit_oggstream& os, bool * & mode_blockflag, int & mode_bits);
void generate_ogg_header_with_triad(Bit_oggstream& os);
};
Expand Down