Adding Fundamental Frequency (F0) to an EmuDB - Hywel-Stoakes/EmuRSummerSchool GitHub Wiki
Preliminaries
First load the database that you will be working on:
require(emuR)
databasepath = "TestDB_emuDB" # set path to current database
test_DB <- load_emuDB(paste0(databasepath), verbose = TRUE) # load the database
Then list all of the tracks that are available in the database:
list_ssffTrackDefinitions(test_DB)
Adding Fundamental Frequency (F0)
To add F0 files we use the ksvF0
function that is found in the wrassp
package. We can then find the parameters using the formals()
function. This will list all of the available parameters that can be changed.
F0.params <- formals(wrassp::ksvF0)
This will load the parameters into the F0.params
object.
When we look at the object we should get the following output:
> F0.params
$listOfFiles
NULL
$optLogFilePath
NULL
$beginTime
[1] 0
$endTime
[1] 0
$windowShift
[1] 5
$gender
[1] "u"
$maxF
[1] 600
$minF
[1] 50
$minAmp
[1] 50
$maxZCR
[1] 3000
$toFile
[1] TRUE
$explicitExt
NULL
$outputDirectory
NULL
$forceToLog
useWrasspLogger
$verbose
[1] TRUE
In order to change one of these parameters we can use the following notation:
F0.params$gender <- "f"
This example will change the gender
parameter to "f" (or female). A full list of the parameters can be found in the wrassp
documentation (?wrassp
).
Once we have set these parameters (also known as onTheFlyParams
) we can run the following command to add an F0 file to the database
add_ssffTrackDefinition(emuDBhandle = test_DB,
name = "F0",
onTheFlyFunctionName = "ksvF0",
onTheFlyParams = F0.params
)
This will add an F0 file to each bundle in your database and also add the F0 signal to the datsbase config file (*_DBconfig.json). In order to actually see the track when you load the DB into the WebApp you must perform an additional step, detailed in the following section.
Making Tracks visible in the Emu WebApp
In order to make the F0 track visible once it has been added to the database we need to edit the perspectives.
list_perspectives(test_DB) # Check the perspectives already in the db (usually just `default`).
# remove_perspective(emuDBhandle = test_DB,
# name = "Pitch") # Use this command to remove a perspective
Add the name of the perspective to the database:
add_perspective(emuDBhandle = test_DB,
name = "Pitch")
The set the order of the signals adding in the F0 as well the waveform (OSCI) and spectrogram (SPEC). These tracks can be omitted if they are not needed
set_signalCanvasesOrder(emuDBhandle = test_DB,
perspectiveName = "Pitch",
order = c("OSCI","SPEC","F0"))
We then set the level (annotation tier) that we would like to include with the perspective (I have just added a single tier/level called etic
in the example below).
set_levelCanvasesOrder(emuDBhandle = test_DB,
perspectiveName = "Pitch",
order = c("etic"))
Serve the Database
Now we can serve the database so we can check the new perspective;
serve(test_DB)