F0RangeFinder: Cycle through each soundfile in a folder and determine F0...

Description Usage Arguments Details Value Output Note Author(s) References See Also Examples

View source: R/F0RangeFinder.r

Description

This function cycles through each soundfile in the specified WaveFolder and helps you quickly determine an optimal F0 range (i.e. 'floor' and 'ceiling' values) for each in a semi-automatic fashion. To do so, a window is created with a RichVisualization-style plot whose (unlabeled) axes are [y = F0 (in Hz), x = Time (in seconds)]. The title of the plot displays the F0 range used to create the file. The F0 values for the highest and lowest points in the current F0 analysis are displayed in the top right (in red) and bottom right (in blue). Thin gridlines appear at every 5 Hz, and thick gridlines appear at every 10 Hz, to visually guide you. You can then type various commands into the R console:

  1. Type an F0 range delimited by a dash, i.e. something like "75-500", to re-run the F0 analysis with that range.

  2. z moves to the next file (and saves the F0 range currently displayed in the title of the plot).

  3. p plays the current soundfile.

  4. s 'snaps' the F0 range to the range defined by the points in the current plot.

  5. q quits the analysis at any time (e.g. to take a break).

Your decisions are stored in three ways:

  1. All relevant information is printed to the R console, hence every step of your analysis can be reconstructed by glancing over the history in the R console.

  2. Depending on the Output argument, a Pitch Object, PitchTier, or Pitch Listing is created in PitchFolder for every file you process, using the floor and ceiling values you ultimately decided on.

  3. A dataframe is returned containing the filenames for every file you processed as well as each's floor and ceiling values. For details, see 'Value' section below.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
F0RangeFinder(
	WaveFolder,
	PitchFolder,
	StartAt=1,
	Output="object",
	OutputExtension=NULL,
	Overwrite=FALSE,
	StartingRange=c(74.99,500.01),
	Next="z",
	Play="p",
	Snap="s",
	Quit="q",
	Delete=FALSE,
	Dataframe,
	Width=10,
	Height=5
)

Arguments

WaveFolder

Path to the folder on your computer that contains the soundfiles to be processed. May not contain any spaces, and must end in either a slash ('/') or a backslash ('\'). Each soundfile therein must end in either a .wav or .WAV file extension.

PitchFolder

Path to the folder on your computer where you would like to save the various pitch-related files that are created as a byproduct of using this function. May not contain any spaces, and must end in either a slash ('/') or a backslash ('\').

StartAt

Which soundfile to start processing from. Can be specified either as an index (e.g. 5 for the 5th file) or as a filename (e.g. MySound.wav). Defaults to 1, hence it will start at the first file and work through all of them.

Output

The storage format of the pitch-related files that are created as a byproduct of using this function. Can be set to values in three different formats: "object"/"tier"/"listing" "o"/"t"/"l", or 1/2/3. See 'Output' section below for more details.

OutputExtension

Determines the file extension of the output file. Must begin with a period. By default (i.e. if OutputExtension is left NULL, it depends on the Output argument. If "object" (or equivalent), it is .Pitch. If "tier", it is .PitchTier. If "listing", it is '.txt'.

Overwrite

If any files already exist in PitchFolder, defines whether over-writing should occur. Defaults to FALSE, thus protecting against accidental loss of data.

StartingRange

A numeric (or integer) vector of length 2 specifying the F0 range to be used as the first approximation for every file. Defaults to c(74.99, 500.01), i.e. effectively [75, 500] except the values are bumped by +/-0.01 as an explicit marker that these are the initial values (and not an ultimately-decided F0 range).

Next

The text to type to move to the next file. Defaults to "z" (since this key is on the corner of the keyboard and close to the 's' key for Snap).

Play

The text to type to play the soundfile. Defaults to "p".

Snap

The text to type to 'snap' the F0 range to the range defined by the points in the current plot (i.e. the minimum and maximum F0 values of the observed points). Defaults to "s".

Quit

The text to quit the analysis at any time (e.g. to take a break). Defaults to "q".

Delete

Whether the .Pitch objects created as a byproduct of using this function should be deleted. Useful to clean up unnecessary clutter in PitchFolder, especially if Output is set to "tier" or "listing".

Dataframe

A dataframe created from a previous run of this function. Useful for picking up where one left off, e.g. after taking a break. For details, see 'Value' section below.

Width

Width of the window to be created. Defaults to 10.

Height

Height of the window to be created. Defaults to 5.

Details

  1. WaveFolder and PitchFolder are the only arguments that must be specified. It is recommended that they be set to two 'sister' folders to each other (hence one should *not* be a subdirectory of the other).

  2. The filename root will be shared between the wave file its various derivative pitch files. Thus, if a wave file is called MySound.wav, its associated Pitch object, for instance, will be called MySound.Pitch.

  3. While using this function, the console should be kept visible on the screen so that it can be typed into. As such, once the window pops up, it is recommended to split the screen 50-50 between the F0RangeFinder() window and the R console.

  4. It is recommended to provide F0 ranges in the format [Floor,Ceiling], but it is fine if these are switched and instead the information is provided in the order [Ceiling,Floor]. (Both orders are supported throughout the code.)

Value

Returns a dataframe with three columns: Filename, Floor, and Ceiling. When running this function, the result should be stored in a variable, e.g. x=F0RangeFinder(...). This can then be passed to a future run of the F0RangeFinder() function via the Dataframe argument. Due to this functionality, it is possible to stop in the middle of one's analysis (e.g. for a break) and later pick up from where your left off. When doing so, simply specify the StartAt argument to indicate where you would like to resume from.

Output

The pitch-related files that are created as a byproduct of using this function can be stored in three different formats:

  1. If Output is set to "object", "o", or 1, it will be in Pitch Object format (which stores all the rich details of Praat's F0 analysis).

  2. If Output is set to "tier", "t", or 2, it will be in PitchTier format, which only contains information about the highest-ranked candidate in voiced frames.

  3. If Output is set to "listing", "l", or 3, it will be in (headerless) Pitch Listing format - which contains the same information as a PitchTier but is tab-delimited (and hence is easy to read into R and copy-paste into spreadsheet software).

The default is "object" since the conversion to the other two formats involves a loss of information.

Note

Note that while the Next argument determines how to proceed to the next file, it is not possible to go backwards to the previous ile. If it ever becomes necessary to do so, simply do the [Quit] command (e.g. "q") to terminate the code and then adjust the "StartAt" index accordingly.

Author(s)

Aaron Albin (http://www.aaronalbin.com/)

References

This function is not directly referenced in, but was used for, the following dissertation:

See Also

This function draws on ToPitch and ReadPitch for the F0 analyses. The plotting recycles much code from RichVisualization. Much of this function draws on the PraatR package (which is a dependency for the 'intonation' package as a whole).

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
## Not run: 

# Basic usage
F0Ranges1 = F0RangeFinder(
	WaveFolder="C:/Users/MyUsername/Desktop/Wave/",
	PitchFolder="C:/Users/MyUsername/Desktop/Pitch/"
)

# Resuming from where you left off (e.g. on file 12)
F0Ranges2 = F0RangeFinder(
	WaveFolder="C:/Users/MyUsername/Desktop/Wave/",
	PitchFolder="C:/Users/MyUsername/Desktop/Pitch/"
	StartAt=12,
	Dataframe=F0Ranges1
)

# Saving in a PitchTier format and making it have a '.txt' extension
F0Ranges3 = F0RangeFinder(
	WaveFolder="C:/Users/MyUsername/Desktop/Wave/",
	PitchFolder="C:/Users/MyUsername/Desktop/Pitch/"
	Output="tier",
	OutputExtension=".txt"
)

## End(Not run)

usagi5886/intonation documentation built on Dec. 9, 2019, 3:46 a.m.