| Sound {R.audio} | R Documentation |
Package: R.audio
Class Sound
Object
~~|
~~+--Sound
Directly known subclasses:
public static class Sound
extends Object
Sound(samples=NULL, samplesPerSecond=NULL, bitsPerSample=NULL, signed=TRUE)
samples |
|
samplesPerSecond |
Samples per second. |
bitsPerSample |
Number of bits per sample to use. |
signed |
If TRUE, signed integers are used, otherwise not. |
Methods:
as.character | - | |
avgBytesPerSecond | - | |
bitsPerSample | - | |
fft | - | |
generateTone | - | |
nbrOfChannels | - | |
nbrOfSamples | - | |
nbrOfSeconds | - | |
periodogram | - | |
play | - | |
playStop | - | |
plot | - | |
plotPeriodogram | - | |
read | - | |
readAU | - | |
readWAV | - | |
reverse | - | |
samplesPerSecond | - | |
write | - | |
writeAU | - | |
writeWAV | - |
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clone, detach, equals, extend, finalize, gc, getEnvironment, getFields, getInstanciationTime, getStaticInstance, hasField, hashCode, ll, load, objectSize, print, save
Henrik Bengtsson (http://www.braju.com/R/)
## Not run: # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Load all audio files found in the data directory of this package
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
path <- system.file("sounds", package="R.audio")
files <- list.files(path, pattern="[.](au|wav)$", full.names=TRUE)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Play the sounds
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
for (file in files) {
cat(file, " - ", sep="");
sound <- Sound$read(file, verbose=F)
print(sound)
plot(sound, main=file, cex.main=0.8)
play(sound)
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Generate new sounds from scratch
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create a 3 seconds (8-bit) 1000Hz tone (with 22500 samples/s)
s1 <- Sound$generateTone(1000, nbrOfSeconds=3)
# Create a 3 seconds (8-bit) 1002Hz tone (with 22500 samples/s)
s2 <- Sound$generateTone(1002, nbrOfSeconds=3)
# Mix them together. Notice wowing effect of 2Hz == (1002-1000)Hz
s <- clone(s1)
paste(s, s2)
# Display the sound graphically
plot(s)
## End(Not run)