Description Usage Arguments Details Value Output Note Author(s) References See Also Examples
View source: R/F0RangeFinder.r
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:
Type an F0 range delimited by a dash, i.e. something like "75-500"
, to re-run the F0 analysis with that range.
z
moves to the next file (and saves the F0 range currently displayed in the title of the plot).
p
plays the current soundfile.
s
'snaps' the F0 range to the range defined by the points in the current plot.
q
quits the analysis at any time (e.g. to take a break).
Your decisions are stored in three ways:
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.
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.
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.
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
)
|
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 (' |
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 (' |
StartAt |
Which soundfile to start processing from. Can be specified either as an index (e.g. |
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: |
OutputExtension |
Determines the file extension of the output file. Must begin with a period. By default (i.e. if OutputExtension is left |
Overwrite |
If any files already exist in PitchFolder, defines whether over-writing should occur. Defaults to |
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 |
Next |
The text to type to move to the next file. Defaults to |
Play |
The text to type to play the soundfile. Defaults to |
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 |
Quit |
The text to quit the analysis at any time (e.g. to take a break). Defaults to |
Delete |
Whether the .Pitch objects created as a byproduct of using this function should be deleted. Useful to clean up unnecessary clutter in |
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. |
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).
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
.
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.
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.)
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.
The pitch-related files that are created as a byproduct of using this function can be stored in three different formats:
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).
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.
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 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.
Aaron Albin (http://www.aaronalbin.com/)
This function is not directly referenced in, but was used for, the following dissertation:
Albin, A. (2015). Typologizing native language influence on intonation in a second language: Three transfer phenomena in Japanese EFL learners. (Doctoral dissertation). Indiana University, Bloomington. http://dx.doi.org/10.5967/K8JW8BSC
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).
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.