colugomusic / blahdio Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Using the following code, I get an overflow (e.g. sample value wrapping around from +1 to -1 at the peak of the sine wave) - only at 32 bit:
`
blahdio::AudioDataFormat write_format;
uint32_t num_frames = 44100 * 10;
write_format.bit_depth = 32;
write_format.num_channels = 2;
write_format.num_frames = num_frames;
write_format.sample_rate = 44100;
blahdio::AudioWriter writer("/Users/marek/Desktop/file.wv", blahdio::AudioType::WavPack, write_format);
blahdio::AudioWriter::Callbacks writer_callbacks;
writer_callbacks.should_abort = []() { return false; };
double phase = 0.0;
writer_callbacks.get_next_chunk = [&](float* buffer, std::uint64_t frame, std::uint32_t num_frames) {
for(int i = 0; i < num_frames; i++) {
float o = sin(phase);
phase += 3.14159*2 * 256 / 44100.0;
buffer[i*2] = o;
buffer[i*2+1] = o;
}
};
writer.write_frames(writer_callbacks, 512); // Will throw an exception if an error
`
screenshot:
Not important to me, as 32 bit audio files are overkill in my case, but I'm guessing it's a float math rounding problem maybe in wavpack_writer.cpp
when using AudioReader with a Stream
added this to audio_reader.cpp to fix it.
AudioReader::AudioReader(const blahdio::AudioReader::Stream& stream, AudioType type_hint) : impl_(std::make_shared<impl::AudioReader>(stream, type_hint)) { }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.