Heidi Liu
Heidi Liu

Reputation: 13

How to get the frequency array and extract a range of frequency from wav file

readWave('hello.wav',from=0,to=1,units='seconds')
plot(hello@left,xlab="time",ylab="freq")  

But how to get the frequency array before applying short-time fourier transform and take out a specific range of the frequency in R? For example, [60,300] Hz for adult men and save it as another wav. file.

Upvotes: 1

Views: 672

Answers (1)

AkselA
AkselA

Reputation: 8846

It sounds like you're asking for a frequency band-pass filter. The package seewave has a suitable function, fir, (and a lot of other useful things).

library(tuneR)
library(seewave)

hello <- readWave("hello.wav")

hello.bp <- fir(hello, from=60, to=300, output="Wave")
hello.bp <- normalize(hello.bp, unit=as.character(hello.bp@bit))
meanspec(hello.bp, log="x")
writeWave(hello.bp, "hello.bp.wav")

Upvotes: 2

Related Questions