Title: | Read and Write WAV Files |
---|---|
Description: | Efficiently read and write Waveform (WAV) audio files <https://en.wikipedia.org/wiki/WAV>. Support for unsigned 8 bit Pulse-code modulation (PCM), signed 12, 16, 24 and 32 bit PCM and other encodings. |
Authors: | Daniel Falbel [aut, cre, cph], Posit, PBC [cph], David Reid [cph] (For the vendored dr_wav.h code.) |
Maintainer: | Daniel Falbel <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9000 |
Built: | 2024-11-18 03:08:19 UTC |
Source: | https://github.com/mlverse/wav |
Efficiently read and write WAV files.
read_wav(path) write_wav(x, path, sample_rate = 44100, bit_depth = 32, ..., normalize = TRUE)
read_wav(path) write_wav(x, path, sample_rate = 44100, bit_depth = 32, ..., normalize = TRUE)
path |
Path to file that will be read or written to. |
x |
Numeric matrix with dimensions |
sample_rate |
Sample rate in Hz of the associated samples. |
bit_depth |
Bit depth of associated samples. This only affects the precision data is saved to the file. |
... |
Currently unused. |
normalize |
Boolean idicating wheter integers should be normalized before
writing. Only used when |
When reading: A numeric matrix with samples. It also contains the attributes sample_rate
and bit_depth
.
When writing: A boolean which is TRUE
if writing was sucessful and FALSE
otherwise.
write_wav()
: Write a wav file.
x <- matrix(sin(440 * seq(0, 2*pi, length = 44100)), nrow=1) tmp <- tempfile(fileext = ".wav") write_wav(x, tmp) y <- read_wav(tmp) all.equal(as.numeric(x), as.numeric(y), tolerance = 1e-7)
x <- matrix(sin(440 * seq(0, 2*pi, length = 44100)), nrow=1) tmp <- tempfile(fileext = ".wav") write_wav(x, tmp) y <- read_wav(tmp) all.equal(as.numeric(x), as.numeric(y), tolerance = 1e-7)