Here's a potential solution that loops over all channels of a multi-channel wav file. It's not that pretty or concise, but it works.
First, let's grab a multi-channel wave file as a test dataset
### Dataset Start ###
# Grab some open-access multi-channel wav data from a relatively short 3-channel
# recording from a dodgy sonobuoy.
# File is approximately 3MB.
wavURL <- 'https://data.aad.gov.au/eds/api/dataset/41072dc7-996b-436e-b31a-776f28de07bf/object/download?prefix=AAS_4600_ENRICH_Sonobuoy_Data/audio/20190221/INV_20190221_013959_828.wav'
# Specify the file name to save the file on your computer
wavFile<-'INV_20190221_013959_828.wav'
# Call the download.file() function, passing in the URL and file name/location as arguments
download.file(wavURL, wavFile, mode = "w")
### Dataset End ##
Now we load the data and filter it in a for-loop. We plot the unfiltered data in the columns on the left, and the filtered data in the columns on the right. I've used seewave::oscillo to view the results here and confirm that the data look filtered, but one could remove the calls to 'oscillo' if you don't care to plot the results.
# Read the first 10 ms of the data from all three channels
wav <- tuneR::readWave(wavFile,header = F,units = "seconds",from = 0,to=0.01)
# Placeholder for filtered data -- same size as original data
wavFiltData <- [email protected];
op<-par(mfrow=c(3,2),mar=c(4.5,4,2,2))
for (i in 1:nchannel(wav)) {
seewave::oscillo(wav,channel=i)
wavFiltData[,i] <- seewave::bwfilter(wav,from=7400, to=7600,channel=i)
# Edit: replaced wavFilt in line below with wavFiltData
# to fix the error found by WMXZ
seewave::oscillo(wavFiltData, [email protected], channel=i)
}
# Convert data back into a WaveMC format
wavFilt <- WaveMC(wavFiltData, [email protected], bit=wav@bit)