bits {sound} | R Documentation |
Bits per Sample
Description
Get or set the bits
parameter (the sampling quality) of a Sample object or a wav file.
Usage
bits(s)
bits(s) <- value
setBits(s,value)
Arguments
s |
a Sample object, or a string giving the name of a wav file. |
value |
the number of bits per sample: 8, 16 or 24. |
Details
The replacement form can be used to reset the sampling quality of a Sample object, that is the number of bits per sample (8 or 16). Here, filenames are not accepted.
Value
For bits
, the bits parameter (number of bits per sample) of the Sample object (8, 16 or 24).
For setBits
, a Sample object with the new bits
parameter.
Note
Changing the sampling quality of a Sample object does not affect its actual data but only its $bits
flag. The sampling quality is only used when a Sample object is played or saved to disk. Internally, R always uses doubles for the waveform.
An 8 bit sample needs only half the disk space compared to a 16 bit sample, but it has a lower sound quality.
Note also that 24 bit samples cannot be played by every wav file player.
Author(s)
Author: Matthias Heymann [aut], Stefan Langenberg [cre] (<https://orcid.org/0000-0001-5817-5469>)
Maintainer: Stefan Langenberg <langenberg@uni-bonn.de>
See Also
Examples
## Not run:
s <- Sine(20000,1,rate=44100,bits=16)
play(s)
print(s)
bits(s) <- 8
play(s) # now worse quality
print(s) # but less disk space
play(setBits(s,16)) # now better quality again, since waveform data was not changed.
## End(Not run)