multiple_sounds: Multiple sound files

Description Usage Arguments Note Examples

View source: R/multiple_sounds.R

Description

Function to extract the specified index from all the wav or flac files in a directory. The results, including the filename and wave technical details, are saved to a csv file. If the computer has multiple cores, it can run files in parallel.

Usage

1
2
multiple_sounds(directory, resultfile, soundindex, no_cores = 1, 
flac = FALSE, from = NA, to = NA, units = NA, ...)

Arguments

directory

a valid directory, readable by the user, that contains the wav files.

resultfile

name of the text file to which write the results in comma-separated values format.

soundindex

which index to calculate:

  • ndsi

  • acoustic_complexity

  • acoustic_diversity

  • acoustic_evenness

  • bioacoustic_index

  • H from the seewave package

no_cores

number of cores to use when calculating the indices. Can be max to use all cores, -1 to use all but one core, or any positive integer. Default is 1. Uses the parallel package.

flac

logical variable to indicate that the files are in FLAC format. FLAC must be installed in the system (see note below). Uses the function wav2flac of seewave.

from

tells readWave where to start loading the files. All three arguments from, to, and units must be specified at the same time, if used.

to

tells readWave where to stop loading the files. All three arguments from, to, and units must be specified at the same time, if used.

units

tells readWave which units to use to determine the start and stop points to load the files. The options are "samples", "seconds", "minutes", or "hours". All three arguments from, to, and units must be specified at the same time, if used.

...

additional variables to pass to the selected function. See each function's help for details.

Note

FLAC stands for Free Lossless Audio Codec. Files in FLAC format have been compressed without destruction of data, which happens in lossy compression codecs like the popular MP3. Files can be between 40-60% of the size of the original wav file, although this value depends on the contents. For more information and to download FLAC, visit http://xiph.org/flac/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
	## Not run: 
		#Calculate the ACI of all the wav
		# files in the directory "/home/user/wavs/"
		# using the function acoustic_complexity
		multiple_sounds(directory = "/home/user/wavs/", 
			resultfile = "/home/user/results.csv", 
			soundindex = "acoustic_complexity")
		
		#Calculate the same as above using 12000Hz as the
		# maximum frequency instead of the default.
		multiple_sounds(directory = "/home/user/wavs/", 
			resultfile = "/home/user/results.csv", 
			soundindex = "acoustic_complexity", max_freq = 12000)
			
		#Calculate the same as above using two cores
		multiple_sounds(directory = "/home/user/wavs/", 
			resultfile = "/home/user/results.csv", 
			soundindex = "acoustic_complexity", no_cores = 2)
			
		#Calculate the same as above using all the cores
		# the computer has
		multiple_sounds(directory="/home/user/wavs/", 
			resultfile = "/home/user/results.csv", 
			soundindex = "acoustic_complexity", no_cores = "max")
			
		#Calculate the same as above using all but one cores
		multiple_sounds(directory = "/home/user/wavs/", 
			resultfile = "/home/user/results.csv", 
			soundindex = "acoustic_complexity", no_cores = -1)
		
## End(Not run)
	

soundecology documentation built on May 2, 2019, 3:21 a.m.