Learn R Programming

sound (version 1.1)

bits: 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 or 16.

Value

  • For bits, the bits parameter (number of bits per sample) of the Sample object, 8 or 16. For setBits, a Sample object with the new bits parameter.

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.

See Also

fitSampleParameters

Examples

Run this code
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.

Run the code above in your browser using DataLab