Question

I R, thanks to the library sound, we are able to create a sine wave:

s1 <- Sine(650, 1, 44100, 16, 2)

Plotting the waveform we obtain an image like this:

plot(s1[1:100])

waveform

The waveform moves in the interval [-1, +1]. If I play it, to what deciBel does it correspond?

How to generate a wave sound (with the same parameters), with a specified deciBel level (i.e. a wave sound, frequency 650Hz, duration 1 sec, sampling rate 44100, 16 bits, 2 channels, 55dB)?

Thanks in advance!

Was it helpful?

Solution

So I guess you want to change the amplitude right? There is no straightforward way to change amplitude in sound the way you want, because it's very basic package. Try tuneR or seewave packages for much more advanced options and control (for example afilter in seewave could be a good solution, but unfortunately I couldn't run it in R 2.14 - not compatible).

What you could do in a simple way is to use normalize to change the volume, but it doesn't work for the 'default' amplitude in sound package. For example, if you produce this sine wave

 s1 <- .6*Sine(650, 1, 44100, 16, 2)  

you can normalize it by

 s2 <- normalize(s1) 

And you can hear (and see on the plot) that the s2 is louder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top