vignettes/sing_happy_birthday_page.Rmd
sing_happy_birthday_page.Rmd
As mentioned in our paper, the SAA
is built in a modular
way, meaning functionality can be used from its dependent packages, like
musicassessr
.
musicassessr
has a special page type called
record_audio_page
, which does just that: allows you to
create a page which records and stores audio data.
We’re going to harness this and make our own function which returns a
“Sing Happy Birthday” page. This is really just a
record_audio_page
with some custom text:
library(musicassessr)
# Create a "Sing Happy Birthday Page"
sing_hbd <- function() {
record_audio_page(label = "sing_hbd",
page_text = "Please sing happy birthday!",
get_answer = musicassessr::get_answer_simple_pyin_summary,
auto_next_page = TRUE)
}
Note that, for the get_answer
function, we use a
function which summarises what the user sung with some descriptive
statistics. Type the following in your R console for more
information:
?musicassessr::get_answer_simple_pyin_summary
We can now include our new page, or a list of pages, if we wanted, by
using the append_trial_block_before
or
append_trial_block_after
arguments to the SAA
functions.
SAA
with the new Happy Birthday Page at the
beginning of the protocol:
library(SAA)
SAA_standalone(app_name = "sing_hbd",
append_trial_block_before = sing_hbd())
SAA_standalone(app_name = "sing_hbd",
append_trial_block_after = sing_hbd())
library(psychTestR)
password <- "demo"
timeline <- join(
sing_hbd(),
# Make sure results are saved to disk
elt_save_results_to_disk(complete = TRUE),
# A "final_page" is required at the end of a psychTestR timeline
final_page("You have completed the study!")
)
make_test(
elts = timeline,
opt = test_options(title = "Melody Singing", admin_password = password))
By the way, a “Sing Happy Birthday” page is already packaged as part
of musicassessr
. Type the following into your R
console for more information:
?musicassessr::sing_happy_birthday_page