forked from Redacted/ReMixer
Mixing Test (Setup both sounds & they'll playback together)
This commit is contained in:
@@ -15,6 +15,12 @@ private:
|
||||
SampleRate sample_rate;
|
||||
StreamMode num_channels;
|
||||
public:
|
||||
|
||||
static Sound FromOGGVorbisFile(const std::filesystem::path& file_name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<char> getAudioData();
|
||||
void setAudioData(const std::vector<char>& audioData);
|
||||
void setNumberOfChannels(StreamMode mode);
|
||||
@@ -25,22 +31,3 @@ public:
|
||||
[[nodiscard]] const char* ptr() const { return audio_data.data();}
|
||||
Sound() = default;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// Short (sub-10-second) audio clips via OGG vorbis format.
|
||||
class SFX : public Sound {
|
||||
public:
|
||||
SFX() = default;
|
||||
SFX(const std::string& sfx_file_path);
|
||||
};
|
||||
|
||||
/// Longer (>10 second) audio via WAV format.
|
||||
class Song : public Sound {
|
||||
public:
|
||||
Song() = default;
|
||||
Song(const std::filesystem::path& song_file_path)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
@@ -526,29 +526,9 @@ static void list_server_info(pa_context* c, pa_server_info* i, void* userdata)
|
||||
pa_threaded_mainloop_signal(p->mainloop, 0);
|
||||
}
|
||||
|
||||
|
||||
int mix_sample_s16_pcm(int16_t a, int16_t b)
|
||||
char mix_sample_s16_pcm(char a, char b)
|
||||
{
|
||||
|
||||
return (a + b) / 2.f;
|
||||
//int m;
|
||||
|
||||
//a += 32768;
|
||||
//b += 32768;
|
||||
|
||||
//if ((a < 32768) || (b < 32768)) {
|
||||
// Viktor's first equation when both sources are quiet.
|
||||
// (i.e. less than middle of the dynamic range)
|
||||
// m = a * b / 32768;
|
||||
//} else {
|
||||
// Viktor's second equation when one or both sources are loud.
|
||||
// m = 2 * (a + b) - (a * b) / 32768 - 65535;
|
||||
//}
|
||||
// Output is unsigned (0..65536) so convert back to signed (-3
|
||||
//if (m == 65536) m = 65535;
|
||||
//m -= 32768;
|
||||
|
||||
//return m;
|
||||
}
|
||||
|
||||
// this dick
|
||||
|
@@ -15,8 +15,20 @@ void decodeVorbis(const char* inputFile, const char* outputFile)
|
||||
fclose(inFile);
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << vf.pcmlengths << " pcmlengths" << std::endl;
|
||||
std::cout << vf.pcm_offset << " pcm_offset" << std::endl;
|
||||
|
||||
vorbis_info* vi = ov_info(&vf, -1);
|
||||
|
||||
|
||||
std::cout << vi->channels << " channels" << std::endl;
|
||||
std::cout << vi->version << " version" << std::endl;
|
||||
std::cout << vi->rate << " rate" << std::endl;
|
||||
std::cout << vi->bitrate_lower << " bitrate_lower" << std::endl;
|
||||
std::cout << vi->bitrate_nominal << " bitrate_nominal" << std::endl;
|
||||
std::cout << vi->bitrate_upper << " bitrate_upper" << std::endl;
|
||||
|
||||
std::ofstream outFile(outputFile, std::ios::binary);
|
||||
if (!outFile.is_open()) {
|
||||
std::cerr << "Error opening output file." << std::endl;
|
||||
@@ -29,6 +41,8 @@ void decodeVorbis(const char* inputFile, const char* outputFile)
|
||||
int current_section;
|
||||
long bytes;
|
||||
|
||||
// Data is read as 2-byte signed words, but we store into a char buffer?
|
||||
|
||||
while ((bytes = ov_read(&vf, pcmout, sizeof(pcmout), 0, 2, 1, ¤t_section)) > 0) {
|
||||
outFile.write(pcmout, bytes);
|
||||
}
|
||||
|
Reference in New Issue
Block a user