diff --git a/404.html b/404.html index c9d0ffb..d9d8292 100644 --- a/404.html +++ b/404.html @@ -21,7 +21,7 @@ dynaSpec - 1.0.3 + 1.0.2 diff --git a/authors.html b/authors.html index e280184..78228a2 100644 --- a/authors.html +++ b/authors.html @@ -7,7 +7,7 @@ dynaSpec - 1.0.3 + 1.0.2 @@ -46,13 +46,13 @@ Citation Araya-Salas M (2024). dynaSpec: Dynamic Spectrogram Visualizations. -R package version 1.0.3, https://github.com/maRce10/dynaSpec. +R package version 1.0.2, https://github.com/maRce10/dynaSpec. @Manual{, title = {dynaSpec: Dynamic Spectrogram Visualizations}, author = {Marcelo Araya-Salas}, year = {2024}, - note = {R package version 1.0.3}, + note = {R package version 1.0.2}, url = {https://github.com/maRce10/dynaSpec}, } diff --git a/index.html b/index.html index 4a1c320..db3a7bb 100644 --- a/index.html +++ b/index.html @@ -23,7 +23,7 @@ dynaSpec - 1.0.3 + 1.0.2 @@ -78,7 +78,7 @@ #load package library(dynaSpec) -Installation of external dependencies can be tricky on operating systems other than Linux. An alternative option is to run the package through google colab. This colab notebook explain how to do this step-by-step. +Installation of external dependencies can be tricky on operating systems other than Linux. An alternative option is to run the package through google colab. This colab notebook explain how to do that step-by-step. Background @@ -110,7 +110,7 @@ Marcelo’s Approach: width = 1000, height = 500, res = 120, file.name = "default.mp4") - + Black and white spectrogram: @@ -123,7 +123,7 @@ Marcelo’s Approach: res = 120, file.name = "black_and_white.mp4", collevels = seq(-100, 0, 5)) - + A spectrogram with black background (colbg = “black”): @@ -135,7 +135,7 @@ Marcelo’s Approach: width = 1000, height = 500, res = 120, file.name = "black.mp4", colbg = "black") - + Slow down to 1/2 speed (speed = 0.5) with a oscillogram at the bottom (osc = TRUE): @@ -149,7 +149,7 @@ Marcelo’s Approach: speed = 0.5, osc = TRUE, colwave = "#31688E99") - + Long-billed hermit song at 1/5 speed (speed = 0.5), removing axes and looping 3 times (loop = 3: @@ -164,7 +164,7 @@ Marcelo’s Approach: file.name = "no_axis.mp4", colbg = "black", speed = 0.2, axis.type = "none", loop = 3) - + Visualizing a northern nightingale wren recording from xeno-canto using a custom color palette: @@ -180,7 +180,7 @@ Marcelo’s Approach: height = 250, res = 100, collevels = seq(-40, 0, 5), file.name = "../nightingale_wren.mp4", colbg = "#2d2d86", lcol = "#FFFFFFE6") - + Spix’s disc-winged bat inquiry call slow down (speed = 0.05): @@ -208,7 +208,7 @@ Marcelo’s Approach: speed = 0.05, fps = 200, buffer = 0, loop = 4, lty = 1, osc = TRUE, colwave = inferno(10, alpha = 0.9)[3]) - + @@ -249,7 +249,7 @@ Further customization collevels = seq(-100, 0, 1), spectro.call = sp_cl, fps = 60, file.name = "yellow_and_green.mp4") - + This option can be mixed with any of the other customizations in the function, as adding an oscillogram: @@ -264,7 +264,7 @@ Further customization spectro.call = sp_cl, fps = 60, file.name = "yellow_and_green_oscillo.mp4") - + A viridis color palette: @@ -287,7 +287,7 @@ Further customization spectro.call = sp_cl, fps = 60, file.name = "viridis.mp4") - + Or simply a gray scale: @@ -309,7 +309,7 @@ Further customization spectro.call = sp_cl, fps = 60, file.name = "gray.mp4") - + The ‘spectro.call’ argument can also be used to add annotations. To do this we need to wrap up both the spectrogram function and the annotation functions (i.e. text(), lines()) in a single function and then save the call to that function: @@ -359,7 +359,7 @@ Further customization spectro.call = ann_cl, fps = 120, file.name = "../viridis_annotated.mp4") - + Finally, the argument ‘annotation.call’ can be used to add static labels (i.e. non-scrolling). It works similar to ‘spectro.call’, but requires a call from text(). This let users customize things as size, color, position, font, and additional arguments taken by text(). The call should also include the argmuents ‘start’ and ‘end’ to indicate the time at which the labels are displayed (in s). ‘fading’ is optional and allows fade-in and fade-out effects on labels (in s as well). The following code downloads a recording containing several frog species recorded in Costa Rica from figshare, cuts a clip including two species and labels it with a single label: @@ -386,7 +386,7 @@ Further customization osc = TRUE, height.prop = c(3, 1), colwave = "#31688E", lty = 3, annotation.call = ann_cll) - + The argument accepts more than one labels as in a regular text() call. In that case ‘start’ and ‘end’ values should be supplied for each label: @@ -408,7 +408,7 @@ Further customization height.prop = c(3, 1),colwave = "#31688E", lty = 3, annotation.call = ann_cll) - + @@ -432,7 +432,7 @@ Workflow #list WAVs included with dynaSpec -(f<-system.file(package="dynaSpec") %>% list.files(pattern=".wav",full.names=T)) +(f<-system.file(package="dynaSpec") |> list.files(pattern=".wav",full.names=T)) #store output and save spectrogram to working directory params <-prep_static_ggspectro(f[1],destFolder="wd",savePNG=T) @@ -456,7 +456,7 @@ Static spectrogram of Dynamic spectrogram of a female barn swallow song - + @@ -477,7 +477,7 @@ Now brighten the spe pagedSpec(p2) Static spectrogram with axis labels for female barn swallow song - + @@ -510,7 +510,7 @@ Static whale song spectrogram Dynamic multipage whale song spectrogram - + @@ -525,7 +525,7 @@ Nighthawk multipage dynamic spec - + Enjoy! Please share your specs with us on Twitter! @M_Araya_Salas & @mattwilkinsbio @@ -573,8 +573,8 @@ Dev status - - + + diff --git a/news/index.html b/news/index.html index 4f86005..93fb3e8 100644 --- a/news/index.html +++ b/news/index.html @@ -7,7 +7,7 @@ dynaSpec - 1.0.3 + 1.0.2 @@ -33,7 +33,7 @@ Changelog -dynaSpec 1.0.3 +dynaSpec 1.0.2 Fix logic for crop and xLim in prep_static_ggspectro() Other fixes to have more predictable behavior of exported MP4 videos using “Matt’s approach” with paged_spectro() Added title parameter to add a title to both static and subsequent paged spectrogram (MP4) diff --git a/pkgdown.yml b/pkgdown.yml index 373b0df..b0a7c17 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 3.1.11 pkgdown: 2.1.1 pkgdown_sha: ~ articles: {} -last_built: 2024-09-28T19:24Z +last_built: 2024-09-28T22:28Z urls: reference: https://marce10.github.io/dynaSpec/reference article: https://marce10.github.io/dynaSpec/articles diff --git a/reference/canyon_wren.html b/reference/canyon_wren.html index da8b37e..973df5e 100644 --- a/reference/canyon_wren.html +++ b/reference/canyon_wren.html @@ -7,7 +7,7 @@ dynaSpec - 1.0.3 + 1.0.2 diff --git a/reference/index.html b/reference/index.html index bc00441..229d3d9 100644 --- a/reference/index.html +++ b/reference/index.html @@ -7,7 +7,7 @@ dynaSpec - 1.0.3 + 1.0.2 diff --git a/reference/paged_spectro.html b/reference/paged_spectro.html index 940ee2a..d40dd84 100644 --- a/reference/paged_spectro.html +++ b/reference/paged_spectro.html @@ -17,7 +17,7 @@ dynaSpec - 1.0.3 + 1.0.2 diff --git a/reference/prep_static_ggspectro.html b/reference/prep_static_ggspectro.html index 2082b5c..54cf1b9 100644 --- a/reference/prep_static_ggspectro.html +++ b/reference/prep_static_ggspectro.html @@ -13,7 +13,7 @@ dynaSpec - 1.0.3 + 1.0.2 diff --git a/reference/scrolling_spectro.html b/reference/scrolling_spectro.html index a407a29..87d6266 100644 --- a/reference/scrolling_spectro.html +++ b/reference/scrolling_spectro.html @@ -7,7 +7,7 @@ dynaSpec - 1.0.3 + 1.0.2 diff --git a/search.json b/search.json index 2820383..4766474 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://marce10.github.io/dynaSpec/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Marcelo Araya-Salas. Author, maintainer.","code":""},{"path":"https://marce10.github.io/dynaSpec/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Araya-Salas M (2024). dynaSpec: Dynamic Spectrogram Visualizations. R package version 1.0.3, https://github.com/maRce10/dynaSpec.","code":"@Manual{, title = {dynaSpec: Dynamic Spectrogram Visualizations}, author = {Marcelo Araya-Salas}, year = {2024}, note = {R package version 1.0.3}, url = {https://github.com/maRce10/dynaSpec}, }"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"dynaspec-dynamic-spectrogram-visualizations","dir":"","previous_headings":"","what":"Dynamic Spectrogram Visualizations","title":"Dynamic Spectrogram Visualizations","text":"set tools generate dynamic spectrogram visualizations video format. FFMPEG must installed order package work (check link instructions link troubleshooting installation Windows). package relies heavily packages seewave tuneR. Please cite dynaSpec follows: Araya-Salas, Marcelo & Wilkins, Matthew R.. (2020), dynaSpec: dynamic spectrogram visualizations R. R package version 1.0.0. Install/load package CRAN follows: install latest developmental version github need R package remotes: Installation external dependencies can tricky operating systems Linux. alternative option run package google colab. colab notebook explain step--step.","code":"# From CRAN would be install.packages(\"dynaSpec\") #load package library(dynaSpec) # and load other dependencies library(viridis) library(tuneR) library(seewave) # From github remotes::install_github(\"maRce10/dynaSpec\") #load package library(dynaSpec)"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"background","dir":"","previous_headings":"","what":"Background","title":"Dynamic Spectrogram Visualizations","text":"package collaboration Marcelo Araya-Salas Matt Wilkins. goal create static dynamic visualizations sounds, ready publication presentation, without taking screen shots another program. Marcelo’s approach (implemented scrolling_spectro() function) shows spectrogram sliding past fixed point sounds played, similar utilized Cornell’s Macaulay Library Sounds. dynamic spectrograms produced natively base graphics. Matt’s approach creates “paged” spectrograms revealed sliding highlight box sounds played, akin Adobe Audition’s spectral view. approach ggplot2 natively, requires setting spec parameters segmenting sound files prep_static_ggspectro(), result processed paged_spectro() generate dynamic spectrogram.","code":""},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"marcelos-approach-scrolling-dynamic-spectrograms","dir":"","previous_headings":"","what":"Marcelo’s Approach: “Scrolling Dynamic Spectrograms”","title":"Dynamic Spectrogram Visualizations","text":"run following examples also need load packages well warbleR >= 1.1.24. can installed follows: dynamic spectrogram canyon wren song viridis color palette: Black white spectrogram: spectrogram black background (colbg = “black”): Slow 1/2 speed (speed = 0.5) oscillogram bottom (osc = TRUE): Long-billed hermit song 1/5 speed (speed = 0.5), removing axes looping 3 times (loop = 3: Visualizing northern nightingale wren recording xeno-canto using custom color palette: Spix’s disc-winged bat inquiry call slow (speed = 0.05):","code":"# From github devtools::install_github(\"maRce10/warbleR\") #load package library(warbleR) data(\"canyon_wren\") scrolling_spectro(wave = canyon_wren, wl = 300, t.display = 1.7, pal = viridis, grid = FALSE, flim = c(1, 9), width = 1000, height = 500, res = 120, file.name = \"default.mp4\") scrolling_spectro(wave = canyon_wren, wl = 300, t.display = 1.7, pal = reverse.gray.colors.1, grid = FALSE, flim = c(1, 9), width = 1000, height = 500, res = 120, file.name = \"black_and_white.mp4\", collevels = seq(-100, 0, 5)) scrolling_spectro(wave = canyon_wren, wl = 300, t.display = 1.7, pal = viridis, grid = FALSE, flim = c(1, 9), width = 1000, height = 500, res = 120, file.name = \"black.mp4\", colbg = \"black\") scrolling_spectro(wave = canyon_wren, wl = 300, t.display = 1.7, pal = viridis, grid = FALSE, flim = c(1, 9), width = 1000, height = 500, res = 120, file.name = \"slow.mp4\", colbg = \"black\", speed = 0.5, osc = TRUE, colwave = \"#31688E99\") data(\"Phae.long4\") scrolling_spectro(wave = Phae.long4, wl = 300, t.display = 1.7, ovlp = 90, pal = magma, grid = FALSE, flim = c(1, 10), width = 1000, height = 500, res = 120, collevels = seq(-50, 0, 5), file.name = \"no_axis.mp4\", colbg = \"black\", speed = 0.2, axis.type = \"none\", loop = 3) ngh_wren <- read_wave(\"https://www.xeno-canto.org/518334/download\") custom_pal <- colorRampPalette( c(\"#2d2d86\", \"#2d2d86\", reverse.terrain.colors(10)[5:10])) scrolling_spectro(wave = ngh_wren, wl = 600, t.display = 3, ovlp = 95, pal = custom_pal, grid = FALSE, flim = c(2, 8), width = 700, height = 250, res = 100, collevels = seq(-40, 0, 5), file.name = \"../nightingale_wren.mp4\", colbg = \"#2d2d86\", lcol = \"#FFFFFFE6\") data(\"thyroptera.est\") # extract one call thy_wav <- attributes(thyroptera.est)$wave.objects[[12]] # add silence at both \"sides\"\" thy_wav <- pastew(tuneR::silence(duration = 0.05, samp.rate = thy_wav@samp.rate, xunit = \"time\"), thy_wav, output = \"Wave\") thy_wav <- pastew(thy_wav, tuneR::silence(duration = 0.04, samp.rate = thy_wav@samp.rate, xunit = \"time\"), output = \"Wave\") scrolling_spectro(wave = thy_wav, wl = 400, t.display = 0.08, ovlp = 95, pal = inferno, grid = FALSE, flim = c(12, 37), width = 700, height = 250, res = 100, collevels = seq(-40, 0, 5), file.name = \"thyroptera_osc.mp4\", colbg = \"black\", lcol = \"#FFFFFFE6\", speed = 0.05, fps = 200, buffer = 0, loop = 4, lty = 1, osc = TRUE, colwave = inferno(10, alpha = 0.9)[3])"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"further-customization","dir":"","previous_headings":"","what":"Further customization","title":"Dynamic Spectrogram Visualizations","text":"argument ‘spectro.call’ allows insert customized spectrogram visualizations. instance, following code makes use color_spectro() function warbleR highlight vocalizations male female house wrens different colors (downloading selection table sound file figshare): male part shown green female part yellow. can wrap color_spectro() call using call() function form base R input scrolling_spectro() using argument ‘spectro.call’: option can mixed customizations function, adding oscillogram: viridis color palette: simply gray scale: ‘spectro.call’ argument can also used add annotations. need wrap spectrogram function annotation functions (.e. text(), lines()) single function save call function: Finally, argument ‘annotation.call’ can used add static labels (.e. non-scrolling). works similar ‘spectro.call’, requires call text(). let users customize things size, color, position, font, additional arguments taken text(). call also include argmuents ‘start’ ‘end’ indicate time labels displayed (s). ‘fading’ optional allows fade-fade-effects labels (s well). following code downloads recording containing several frog species recorded Costa Rica figshare, cuts clip including two species labels single label: argument accepts one labels regular text() call. case ‘start’ ‘end’ values supplied label:","code":"# get house wren male female duet recording hs_wren <- read_wave(\"https://ndownloader.figshare.com/files/22722101\") # and extended selection table st <- read.csv(\"https://ndownloader.figshare.com/files/22722404\") # create color column st$colors <- c(\"green\", \"yellow\") # highlight selections color.spectro(wave = hs_wren, wl = 200, ovlp = 95, flim = c(1, 13), collevels = seq(-55, 0, 5), dB = \"B\", X = st, col.clm = \"colors\", base.col = \"black\", t.mar = 0.07, f.mar = 0.1, strength = 3, interactive = NULL, bg.col = \"black\") # save call sp_cl <- call(\"color.spectro\", wave = hs_wren, wl = 200, ovlp = 95, flim = c(1, 13), collevels = seq(-55, 0, 5), strength = 3, dB = \"B\", X = st, col.clm = \"colors\", base.col = \"black\", t.mar = 0.07, f.mar = 0.1, interactive = NULL, bg.col = \"black\") # create dynamic spectrogram scrolling_spectro(wave = hs_wren, wl = 512, t.display = 1.2, pal = reverse.gray.colors.1, grid = FALSE, flim = c(1, 13), loop = 3, width = 1000, height = 500, res = 120, collevels = seq(-100, 0, 1), spectro.call = sp_cl, fps = 60, file.name = \"yellow_and_green.mp4\") # create dynamic spectrogram scrolling_spectro(wave = hs_wren, wl = 512, osc = TRUE, t.display = 1.2, pal = reverse.gray.colors.1, grid = FALSE, flim = c(1, 13), loop = 3, width = 1000, height = 500, res = 120, collevels = seq(-100, 0, 1), spectro.call = sp_cl, fps = 60, file.name = \"yellow_and_green_oscillo.mp4\") st$colors <- viridis(10)[c(3, 8)] sp_cl <- call(\"color.spectro\", wave = hs_wren, wl = 200, ovlp = 95, flim = c(1, 13), collevels = seq(-55, 0, 5), dB = \"B\", X = st, col.clm = \"colors\", base.col = \"white\", t.mar = 0.07, f.mar = 0.1, strength = 3, interactive = NULL) # create dynamic spectrogram scrolling_spectro(wave = hs_wren, wl = 200, osc = TRUE, t.display = 1.2, pal = reverse.gray.colors.1, grid = FALSE, flim = c(1, 13), loop = 3, width = 1000, height = 500, res = 120, collevels = seq(-100, 0, 1), colwave = viridis(10)[c(9)], spectro.call = sp_cl, fps = 60, file.name = \"viridis.mp4\") st$colors <- c(\"gray\", \"gray49\") sp_cl <- call(\"color.spectro\", wave = hs_wren, wl = 200, ovlp = 95, flim = c(1, 13), collevels = seq(-55, 0, 5), dB = \"B\", X = st, col.clm = \"colors\", base.col = \"white\", t.mar = 0.07, f.mar = 0.1, strength = 3, interactive = NULL) # create dynamic spectrogram scrolling_spectro(wave = hs_wren, wl = 512, osc = TRUE, t.display = 1.2, pal = reverse.gray.colors.1, grid = FALSE, flim = c(1, 13), loop = 3, width = 1000, height = 500, res = 120, collevels = seq(-100, 0, 1), spectro.call = sp_cl, fps = 60, file.name = \"gray.mp4\") # create color column st$colors <- viridis(10)[c(3, 8)] # create label column st$labels <- c(\"male\", \"female\") # shrink end of second selection (purely aesthetics) st$end[2] <- 3.87 # function to highlight selections ann_fun <- function(wave, X){ # print spectrogram color.spectro(wave = wave, wl = 200, ovlp = 95, flim = c(1, 18.6), collevels = seq(-55, 0, 5), dB = \"B\", X = X, col.clm = \"colors\", base.col = \"white\", t.mar = 0.07, f.mar = 0.1, strength = 3, interactive = NULL) # annotate each selection in X for(e in 1:nrow(X)){ # label text(x = X$start[e] + ((X$end[e] - X$start[e]) / 2), y = 16.5, labels = X$labels[e], cex = 3.3, col = adjustcolor(X$colors[e], 0.6)) # line lines(x = c(X$start[e], X$end[e]), y = c(14.5, 14.5), lwd = 6, col = adjustcolor(\"gray50\", 0.3)) } } # save call ann_cl <- call(\"ann_fun\", wave = hs_wren, X = st) # create annotated dynamic spectrogram scrolling_spectro(wave = hs_wren, wl = 200, t.display = 1.2, grid = FALSE, flim = c(1, 18.6), loop = 3, width = 1000, height = 500, res = 200, collevels = seq(-100, 0, 1), speed = 0.5, spectro.call = ann_cl, fps = 120, file.name = \"../viridis_annotated.mp4\") # read data from figshare frogs <- read_wave(\"https://ndownloader.figshare.com/files/22829075\") # cut a couple of species shrt_frgs <- cutw(frogs, from = 35.3, to = 50.5, output = \"Wave\") # make annotation call ann_cll <- call(\"text\", x = 0.25, y = 0.87, labels = \"Frog calls\", cex = 1, start = 0.2, end = 14, col = \"#FFEA46CC\", font = 3, fading = 0.6) # create dynamic spectro scrolling_spectro(wave = shrt_frgs, wl = 512, ovlp = 95, t.display = 1.1, pal = cividis, grid = FALSE, flim = c(0, 5.5), loop = 3, width = 1200, height = 550, res = 200, collevels = seq(-40, 0, 5), lcol = \"#FFFFFFCC\", colbg = \"black\", fps = 60, file.name = \"../frogs.mp4\", osc = TRUE, height.prop = c(3, 1), colwave = \"#31688E\", lty = 3, annotation.call = ann_cll) # make annotation call for 2 annotations ann_cll <- call(\"text\", x = 0.25, y = 0.87, labels = c(\"Dendropsophus ebraccatus\", \"Eleutherodactylus coqui\"), cex = 1, start = c(0.4, 7), end = c(5.5, 14.8), col = \"#FFEA46CC\", font = 3, fading = 0.6) # create dynamic spectro scrolling_spectro(wave = shrt_frgs, wl = 512, ovlp = 95, t.display = 1.1, pal = cividis, grid = FALSE, flim = c(0, 5.5), loop = 3, width = 1200, height = 550, res = 200, collevels = seq(-40, 0, 5), lcol = \"#FFFFFFCC\", colbg = \"black\", fps = 60, file.name = \"../frogs_sp_labels.mp4\", osc = TRUE, height.prop = c(3, 1),colwave = \"#31688E\", lty = 3, annotation.call = ann_cll)"},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"workflow","dir":"","previous_headings":"","what":"Workflow","title":"Dynamic Spectrogram Visualizations","text":"Tweak spectrogram settings using prep_static_ggspectro() function – aka prepStaticSpec() – storing results variable. can also just segment export static specs step. exporting PNG testSpec() ggplot function; Import PNG new ggplot raster layer Overlay series translucent highlight boxes disolve away using gganimate","code":"#list WAVs included with dynaSpec (f<-system.file(package=\"dynaSpec\") %>% list.files(pattern=\".wav\",full.names=T)) #store output and save spectrogram to working directory params <-prep_static_ggspectro(f[1],destFolder=\"wd\",savePNG=T)"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"static-spectrogram-of-a-female-barn-swallow-song","dir":"","previous_headings":"","what":"Static spectrogram of a female barn swallow song","title":"Dynamic Spectrogram Visualizations","text":"Static Spectrogram female barn swallow song Static spectrogram axis labels female barn swallow song","code":"#let's add axes femaleBarnSwallow<-prep_static_ggspectro(f[1],destFolder=tempdir(),savePNG=T,onlyPlotSpec = F) #Now generate a dynamic spectrogram paged_spectro(femaleBarnSwallow)"},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"now-brighten-the-spec-using-the-amptrans-parameter","dir":"","previous_headings":"","what":"Now brighten the spec using the ampTrans parameter","title":"Dynamic Spectrogram Visualizations","text":"ampTrans=3 nonlinear signal booster. Basically collapses difference loudest quietest values (higher values= brighter specs); 1 (default) means transformation , also lowered decibel threshold include quieter sounds min_dB=-35; default -30 bgFlood=T makes axis area color plot background. automatically switch white axis font background dark. generate dynamic spectrogram Static spectrogram axis labels female barn swallow song","code":"#note that prep_static_spectro() is tha same as prepStaticSpec() #Also paged_spectro() is the same as pagedSpec() p2<-prepStaticSpec(f[1],min_dB=-35, savePNG=T, destFolder=\"wd\",onlyPlotSpec=F,bgFlood=T,ampTrans=3) pagedSpec(p2)"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"now-also-supports-mp3-files-web-or-local-and-multi-page-dynamic-spectrograms-ie-cropping-and-segmenting-spectrograms-from-larger-recording-files","dir":"","previous_headings":"","what":"Now also supports .mp3 files (web or local) and multi-page dynamic spectrograms (i.e. cropping and segmenting spectrograms from larger recording files)","title":"Dynamic Spectrogram Visualizations","text":"default plot axes labels (onlyPlotSpec=T) crop=12 interpreted : use first 12 seconds file; can also specify interval w/ c(0,12) xLim=3 specifies “page window” .e. many seconds “page” dynamic spectrogram display, 3 sec also limit yLim plot vocalized frequencies 0 700 Hz (0.7 kHz)","code":"whale<-prepStaticSpec(\"http://www.oceanmammalinst.org/songs/hmpback3.wav\", savePNG=T,destFolder=\"wd\",yLim=c(0,.7),crop=12,xLim=3,ampTrans=3) pagedSpec(whale) #Voila 🐋"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"static-whale-song-spectrogram","dir":"","previous_headings":"","what":"Static whale song spectrogram","title":"Dynamic Spectrogram Visualizations","text":"Humpback whale song spectrogram","code":""},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"example-using-xeno-canto-to-generate-a-multi-page-dynamic-spectrogram-of-a-common-nighthawk-call-w-different-color-scheme","dir":"","previous_headings":"","what":"Example using Xeno-Canto to generate a multi-page dynamic spectrogram of a common nighthawk call (w/ different color scheme)","title":"Dynamic Spectrogram Visualizations","text":"","code":"song=\"https://www.xeno-canto.org/sounds/uploaded/SPMWIWZKKC/XC490771-190804_1428_CONI.mp3\" temp=prepStaticSpec(song,crop=20,xLim=4,colPal = c(\"white\",\"black\")) pagedSpec(temp,vidName=\"nightHawk\" ,highlightCol = \"#d1b0ff\",cursorCol = \"#7817ff\")"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"nighthawk-multipage-dynamic-spec","dir":"","previous_headings":"","what":"Nighthawk multipage dynamic spec","title":"Dynamic Spectrogram Visualizations","text":"Enjoy! Please share specs us Twitter! @M_Araya_Salas & @mattwilkinsbio Please cite dynaSpec follows: Araya-Salas, Marcelo Wilkins, Matthew R. (2020), dynaSpec: dynamic spectrogram visualizations R. R package version 1.0.0.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/canyon_wren.html","id":null,"dir":"Reference","previous_headings":"","what":"Acoustic recording of a Catherpes mexicanus (canyon wren) song. — canyon_wren","title":"Acoustic recording of a Catherpes mexicanus (canyon wren) song. — canyon_wren","text":"Acoustic recording Catherpes mexicanus (canyon wren) song.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/canyon_wren.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Acoustic recording of a Catherpes mexicanus (canyon wren) song. — canyon_wren","text":"","code":"data(canyon_wren)"},{"path":"https://marce10.github.io/dynaSpec/reference/canyon_wren.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Acoustic recording of a Catherpes mexicanus (canyon wren) song. — canyon_wren","text":"One Wave object: canyon_wren Catherpes mexicanus recording","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":null,"dir":"Reference","previous_headings":"","what":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"function works object generated prep_static_ggspectro, alias prepStaticSpec(). Video generation time consuming, desired spectrogram parameters set prep step. output mp4 video dynamic spectrogram video. input sound file segmented prep step, resulting video concatenation multiple dynamic spectrogram \"pages.\" page sliding window revealing part static spectrogram played. Temporal width page defined xLim parameter prep_static_ggspectro. can also output temporary segmented files, desired.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"","code":"paged_spectro( specParams, destFolder, vidName, framerate = 30, highlightCol = \"#4B0C6BFF\", highlightAlpha = 0.6, cursorCol = \"white\", delete_temp_files = TRUE )"},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"specParams object returned prep_static_ggspectro destFolder destination output video; setting overwrites setting specParams object vidName expects \"FileName\", .mp4 necessary; supplied, named file used prep_static_ggspectro() framerate default, set 30 (currently supported, animate honor setting) highlightCol default \"#4B0C6BFF\" (purple color match default viridis 'inferno' palette) highlightAlpha opacity highlight box; default 0.6 cursorCol Color leading edge highlight box; default \"white\" delete_temp_files Default= TRUE, deletes temporary files (specs & WAV files used create concatenated video)","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"Nothing returned, though progress file save locations output user. Video play rendering.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"Araya-Salas M & Wilkins M R. (2020). *dynaSpec: dynamic spectrogram visualizations R*. R package version 1.0.0.","code":""},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"Matthew R Wilkins (matt@galacticpolymath.com)","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"","code":"if (FALSE) { # \\dontrun{ #show wav files included with dynaSpec f <- list.files(pattern=\".wav\", full.names = TRUE, path = system.file(package=\"dynaSpec\")) femaleBarnSwallow<-prep_static_ggspectro(f[1],destFolder=tempdir(), onlyPlotSpec = FALSE, bgFlood= TRUE) paged_spectro(femaleBarnSwallow,destFolder=tempdir()) maleBarnSwallow<-prep_static_ggspectro(f[2],destFolder=tempdir(), onlyPlotSpec = FALSE, bgFlood= TRUE,min_dB=-40) paged_spectro(femaleBarnSwallow,destFolder=tempdir()) # Make a multipage dynamic spec of a humpback whale song # Note, we're saving PNGs of our specs in the working directory; to add # axis labels, we set onlyPlotSpec to F, and to make the same background # color for the entire figure, we set bgFlood= TRUE; # The yLim is set to only go to 0.7kHz, where the sounds are for these big whales; #also applying an amplitude transform to boost signal. #This is a longer file, so we're taking the first 12 seconds with crop=12 #xLim=3 means each \"page\" will be 3 seconds, so we'll have 4 dynamic spec pages that get combined humpback <- prep_static_ggspectro( \"http://www.oceanmammalinst.org/songs/hmpback3.wav\",destFolder=tempdir(),savePNG= FALSE, onlyPlotSpec=FALSE,bgFlood= TRUE,yLim=c(0,.7),crop=12,xLim=3,ampTrans=3) #to generate multipage dynamic spec (movie), run the following paged_spectro(humpback,destFolder=tempdir()) # see more examples at https://marce10.github.io/dynaSpec/ } # }"},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"Can used generate single segmented static spectrograms. Works standalone, returned object also intended feed paged_spectro. Workflow: 1) use prep_static_ggspectro crop, filter, segment tweak spectrogram parameters; 2) pass settings paged_spectro generate dynamic spectrogram video.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"","code":"prep_static_ggspectro( soundFile, destFolder, outFilename = NULL, savePNG = FALSE, colPal = \"inferno\", crop = NULL, bg = NULL, filter = NULL, xLim = NULL, yLim = c(0, 10), title = NULL, plotLegend = FALSE, onlyPlotSpec = TRUE, ampTrans = 1, resampleRate = 15000, min_dB = -30, wl = 512, ovlp = 90, wn = \"blackman\", specWidth = 9, specHeight = 3, colbins = 30, ampThresh = 0, bgFlood = FALSE, fontAndAxisCol = NULL, optim = NULL, ... )"},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"soundFile work URLs, full relative paths; handles .mp3 .wav destFolder path directory save output. Needs like \"figures/spectrograms/\" relative working directory. Default=parent folder soundFile. Specify \"wd\" output working directory, gotten [get_wd()] outFilename name output PNG. default=NULL use input name output filename. savePNG logical; Save static spectrograms PNGs? exported destFolder. colPal color palette; one \"viridis\",\"magma\",\"plasma\",\"inferno\",\"cividis\" viridis package 2 value vector (e.g. c(\"white\",\"black\")), defining start end custom color gradient crop subset recording include; default crop=NULL use whole file, 10 sec; number, interpreted crop first X.X sec; c(X1,X2), interpreted trimming specific time interval sec; crop=FALSE, crop , even recordings 10 sec. bg background color (defaults 1st value chosen palette) filter apply bandpass filter? Defaults none (NULL). Expects 'c(0,2)' sound 0 2kHz filtered xLim time limit (x-axis width) seconds spectrograms; .e. page width seconds multi-page dynamic spectrograms (defaults WAV file length, unless file duration >5s). override 5s limit, put xLim=Inf specify desired spectrogram x-axis limit. yLim frequency limits (y-axis); default c(0,10) aka 0-10kHz title string title plots; default=NULL plotLegend logical; include legend showing amplitude colors? default=FALSE onlyPlotSpec logical; want just plot spec leave legend, axes, axis labels? default= TRUE ampTrans amplitude transform boosting spectrum contrast; default=1 (actual dB values); specify decimal number lambda value scales::modulus_trans(); 2.5 good place start. (amplifies loud values , increasing background noise much ) resampleRate number Hz downsample audio spectrogram . simplify audio data speed generation spectrogram. Passed [tuneR::downsample()]. Default=15000 shaves seconds without losing much quality. Put NULL keep original sample rate spectrogram. Audiofile resampled MP4. min_dB minimum decibel (quietest sound) include spec; defaults -30 (-40 include quieter sounds; -20 cut loud sounds) wl window length spectrogram (low values= higher temporal res; high values= higher freq. res). Default 512 good tradeoff; human speech look better 1024 higher, giving higher frequency resolution. ovlp much overlap (percent) sliding windows generate spec? Default 90 looks good, takes longer wn window name (slight tweaks algorithm affect smoothness output) see spectro specWidth width (inches) like make PNG output , saving static spec? specHeight height (inches) like make PNG output , saving static spec? colbins default 30: increasing can smooth color contours, take longer generate spec ampThresh amplitude threshold percent cut recording (try 5 start); default= filtering (high data loss ; recommended; play min_dB ampTrans first) bgFlood want background color spill axis margins? Default=FALSE (.e. white margins) fontAndAxisCol color legend text onlyPlotSpec=TRUE (since margins white, black text); bgFlood=TRUE, color axis margins, labels legend text. supply , picked automatically white black based supplied bg color optim NULL default; experimental feature simplify dataframe FFT-processed waveform used generate spectrogram (currently nothing) ... arguments passed rendering spec (.e. seewave::spectro)","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"list spectrogram parameters, segmented WAV files (segWavs) spectrograms spec; importantly, spec list n=number \"pages\"/segments; first page displayed default","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"Araya-Salas M & Wilkins M R. (2020). *dynaSpec: dynamic spectrogram visualizations R*. R package version 1.0.0.","code":""},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"Matthew R Wilkins (matt@galacticpolymath.com)","code":""},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":null,"dir":"Reference","previous_headings":"","what":"Create scrolling dynamic spectrograms — scrolling_spectro","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"scrolling_spectro create videos single row spectrograms scrolling right left sync'ed sound.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"","code":"scrolling_spectro(wave, file.name = \"scroll.spectro.mp4\", hop.size = 11.6, wl = NULL, ovlp = 70, flim = NULL, pal = seewave::reverse.gray.colors.1, speed = 1, fps = 50, t.display = 1.5, fix.time = TRUE, res = 70, width = 700, height = 400, parallel = 1, pb = TRUE, play = TRUE, loop = 1, lcol = \"#07889B99\", lty = 2, lwd = 2, axis.type = \"standard\", buffer = 1, ggspectro = FALSE, lower.spectro = TRUE, height.prop = c(5, 1), derivative = FALSE, osc = FALSE, colwave = \"black\", colbg = \"white\", spectro.call = NULL, annotation.call = NULL, ...)"},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"wave object class 'Wave'. file.name Character string name output video file. Must include .mp4 extension. Default 'scroll.spectro.mp4'. hop.size numeric vector length 1 specifying time window duration (ms). Default 11.6 ms, equivalent 512 wl 44.1 kHz sampling rate. Ignored 'wl' supplied. wl numeric vector length 1 specifying window length spectrogram, default NULL. supplied, 'hop.size' ignored. ovlp Numeric vector length 1 specifying percent overlap two consecutive windows, spectro. Default 70. flim numeric vector length 2 specifying limits frequency axis (kHz). Default NULL (means 0 Nyquist frequency). pal Character string color palette used. Default 'reverse.gray.colors.1'. speed Numeric vector length 1 indicating speed sound file reproduced (default 1, normal speed). Values < 1 (higher 0) slow values > 1 speed . Note changes speed achieved modifying number frames per second output video. Hence, may want adjust 'fps' video quality considerably affected. fps Numeric vector length 1 specifying number frames per second. t.display Numeric vector length 1 specifying time range displayed spectrogram. fix.time Logical argument control time axis moves along spectrogram remains fixed. Default TRUE (fixed). res Numeric vector length 1 specifying resolution image files (see png). width Numeric vector length 1 specifying width video frame pixels (see png). Default 700. height Numeric vector length 1 specifying height video frame pixels (see png). Default 400. parallel Numeric vector length 1. Controls whether parallel computing applied specifying number cores used. Default 1 (.e. parallel computing). pb Logical argument control progress bar shown. Default TRUE. play Logical argument control video played generated. Default TRUE. loop Logical argument control video formatted played loop (.e. ends start clip). lcol Character string color used vertical line sounds played. Default \"#07889B99\". lty Character string control type line sounds played. Line types can either specified integer (0=blank, 1=solid (default), 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash) one character strings \"blank\", \"solid\", \"dashed\", \"dotted\", \"dotdash\", \"longdash\", \"twodash\", \"blank\" uses 'invisible lines' (.e., draw ).Default 2. lwd Character string control width line sounds played. Default 2. axis.type Character string control style spectrogram axes. Currently 3 options: standard: Y X axes printed default spectro view. minimal: Single lines used denote range defined 1 s 1 kHz X Y axes respectively. none: axis printed (also removes ticks, tick labels, axis labels). buffer Numeric vector length 1 (> 0) specifying time delay start spectrogram scrolling (seconds). Default 1. available loop > 1. ggspectro Logical argument control ggspectro (ggspectro) used instead. Note much less control display parameters ggpsectro = TRUE. Default FALSE. lower.spectro Logical argument control spectrogram full wave object plotted bottom graph. Default TRUE. height.prop Numeric vector length 2 control relative height scrolling lower spectro, respectively. Default c(5, 1). Ignored lower.spectro = FALSE. derivative Logical argument control spectral derivative used instead spectrogram (Sound Analysis Pro, see deriche). Default FALSE. osc Logical argument control oscillogram plotted bottom spectrogram. Default FALSE. Note 'osc' 'lower.spectro' mutually exclusive. colwave Character string control color oscillogram. Default 'black'. colbg Character string control background color. Default 'white'. spectro.call call spectrogram creating function (.e. spectro, color_spectro) generated function call. call replace internal spectrogram creating call. Default NULL. annotation.call call text generated function call. call also include argmuents 'start' 'end' indicate time labels displayed (s).'fading' optional allows fade-fade-effects labels (s well). position ('x' 'y' arguments) 0 1: x = 0, y = 0 corresponds bottom left x = 1, y = 1 corresponds top right position. ... Additional arguments passed spectro customizing spectrograms. Note 'scale' included.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"video file mp4 format working directory scrolling spectrogram.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"function creates videos (mp4 format) single row spectrograms scrolling right left. audio sync'ed spectrograms. Sound files sampling rate 44.1 kHz resampled 44.1 kHz required ffmpeg embeding audio video files.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"Araya-Salas M & Wilkins M R. (2020). dynaSpec: dynamic spectrogram visualizations R. R package version 1.0.0.","code":""},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"Marcelo Araya-Salas (marcelo.araya@ucr.ac.cr)","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"","code":"if (FALSE) { # \\dontrun{ # load example data data(list = c(\"Phae.long1\")) # run function scrolling_spectro(wave = Phae.long1, wl = 300, ovlp = 90, fps = 50, t.display = 1.5, collevels = seq(-40, 0, 5), pal = reverse.heat.colors, grid = FALSE, flim = c(1, 10), res = 120) } # }"},{"path":"https://marce10.github.io/dynaSpec/news/index.html","id":"dynaspec-103","dir":"Changelog","previous_headings":"","what":"dynaSpec 1.0.3","title":"dynaSpec 1.0.3","text":"Fix logic crop xLim prep_static_ggspectro() fixes predictable behavior exported MP4 videos using “Matt’s approach” paged_spectro() Added title parameter add title static subsequent paged spectrogram (MP4) Added resampleRate parameter prep_static_ggspectro() control resolution spectrogram (speed things )","code":""},{"path":"https://marce10.github.io/dynaSpec/news/index.html","id":"dynaspec-101","dir":"Changelog","previous_headings":"","what":"dynaSpec 1.0.1","title":"dynaSpec 1.0.1","text":"CRAN release: 2021-03-09 Fix resampling issue sampling rate waves != 44.1 kHz Fix closing clusters OS != windows","code":""},{"path":"https://marce10.github.io/dynaSpec/news/index.html","id":"dynaspec-100","dir":"Changelog","previous_headings":"","what":"dynaSpec 1.0.0","title":"dynaSpec 1.0.0","text":"CRAN release: 2020-06-22 First release","code":""}] +[{"path":"https://marce10.github.io/dynaSpec/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Marcelo Araya-Salas. Author, maintainer.","code":""},{"path":"https://marce10.github.io/dynaSpec/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Araya-Salas M (2024). dynaSpec: Dynamic Spectrogram Visualizations. R package version 1.0.2, https://github.com/maRce10/dynaSpec.","code":"@Manual{, title = {dynaSpec: Dynamic Spectrogram Visualizations}, author = {Marcelo Araya-Salas}, year = {2024}, note = {R package version 1.0.2}, url = {https://github.com/maRce10/dynaSpec}, }"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"dynaspec-dynamic-spectrogram-visualizations","dir":"","previous_headings":"","what":"Dynamic Spectrogram Visualizations","title":"Dynamic Spectrogram Visualizations","text":"set tools generate dynamic spectrogram visualizations video format. FFMPEG must installed order package work (check link instructions link troubleshooting installation Windows). package relies heavily packages seewave tuneR. Please cite dynaSpec follows: Araya-Salas, Marcelo & Wilkins, Matthew R.. (2020), dynaSpec: dynamic spectrogram visualizations R. R package version 1.0.0. Install/load package CRAN follows: install latest developmental version github need R package remotes: Installation external dependencies can tricky operating systems Linux. alternative option run package google colab. colab notebook explain step--step.","code":"# From CRAN would be install.packages(\"dynaSpec\") #load package library(dynaSpec) # and load other dependencies library(viridis) library(tuneR) library(seewave) # From github remotes::install_github(\"maRce10/dynaSpec\") #load package library(dynaSpec)"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"background","dir":"","previous_headings":"","what":"Background","title":"Dynamic Spectrogram Visualizations","text":"package collaboration Marcelo Araya-Salas Matt Wilkins. goal create static dynamic visualizations sounds, ready publication presentation, without taking screen shots another program. Marcelo’s approach (implemented scrolling_spectro() function) shows spectrogram sliding past fixed point sounds played, similar utilized Cornell’s Macaulay Library Sounds. dynamic spectrograms produced natively base graphics. Matt’s approach creates “paged” spectrograms revealed sliding highlight box sounds played, akin Adobe Audition’s spectral view. approach ggplot2 natively, requires setting spec parameters segmenting sound files prep_static_ggspectro(), result processed paged_spectro() generate dynamic spectrogram.","code":""},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"marcelos-approach-scrolling-dynamic-spectrograms","dir":"","previous_headings":"","what":"Marcelo’s Approach: “Scrolling Dynamic Spectrograms”","title":"Dynamic Spectrogram Visualizations","text":"run following examples also need load packages well warbleR >= 1.1.24. can installed follows: dynamic spectrogram canyon wren song viridis color palette: Black white spectrogram: spectrogram black background (colbg = “black”): Slow 1/2 speed (speed = 0.5) oscillogram bottom (osc = TRUE): Long-billed hermit song 1/5 speed (speed = 0.5), removing axes looping 3 times (loop = 3: Visualizing northern nightingale wren recording xeno-canto using custom color palette: Spix’s disc-winged bat inquiry call slow (speed = 0.05):","code":"# From github devtools::install_github(\"maRce10/warbleR\") #load package library(warbleR) data(\"canyon_wren\") scrolling_spectro(wave = canyon_wren, wl = 300, t.display = 1.7, pal = viridis, grid = FALSE, flim = c(1, 9), width = 1000, height = 500, res = 120, file.name = \"default.mp4\") scrolling_spectro(wave = canyon_wren, wl = 300, t.display = 1.7, pal = reverse.gray.colors.1, grid = FALSE, flim = c(1, 9), width = 1000, height = 500, res = 120, file.name = \"black_and_white.mp4\", collevels = seq(-100, 0, 5)) scrolling_spectro(wave = canyon_wren, wl = 300, t.display = 1.7, pal = viridis, grid = FALSE, flim = c(1, 9), width = 1000, height = 500, res = 120, file.name = \"black.mp4\", colbg = \"black\") scrolling_spectro(wave = canyon_wren, wl = 300, t.display = 1.7, pal = viridis, grid = FALSE, flim = c(1, 9), width = 1000, height = 500, res = 120, file.name = \"slow.mp4\", colbg = \"black\", speed = 0.5, osc = TRUE, colwave = \"#31688E99\") data(\"Phae.long4\") scrolling_spectro(wave = Phae.long4, wl = 300, t.display = 1.7, ovlp = 90, pal = magma, grid = FALSE, flim = c(1, 10), width = 1000, height = 500, res = 120, collevels = seq(-50, 0, 5), file.name = \"no_axis.mp4\", colbg = \"black\", speed = 0.2, axis.type = \"none\", loop = 3) ngh_wren <- read_wave(\"https://www.xeno-canto.org/518334/download\") custom_pal <- colorRampPalette( c(\"#2d2d86\", \"#2d2d86\", reverse.terrain.colors(10)[5:10])) scrolling_spectro(wave = ngh_wren, wl = 600, t.display = 3, ovlp = 95, pal = custom_pal, grid = FALSE, flim = c(2, 8), width = 700, height = 250, res = 100, collevels = seq(-40, 0, 5), file.name = \"../nightingale_wren.mp4\", colbg = \"#2d2d86\", lcol = \"#FFFFFFE6\") data(\"thyroptera.est\") # extract one call thy_wav <- attributes(thyroptera.est)$wave.objects[[12]] # add silence at both \"sides\"\" thy_wav <- pastew(tuneR::silence(duration = 0.05, samp.rate = thy_wav@samp.rate, xunit = \"time\"), thy_wav, output = \"Wave\") thy_wav <- pastew(thy_wav, tuneR::silence(duration = 0.04, samp.rate = thy_wav@samp.rate, xunit = \"time\"), output = \"Wave\") scrolling_spectro(wave = thy_wav, wl = 400, t.display = 0.08, ovlp = 95, pal = inferno, grid = FALSE, flim = c(12, 37), width = 700, height = 250, res = 100, collevels = seq(-40, 0, 5), file.name = \"thyroptera_osc.mp4\", colbg = \"black\", lcol = \"#FFFFFFE6\", speed = 0.05, fps = 200, buffer = 0, loop = 4, lty = 1, osc = TRUE, colwave = inferno(10, alpha = 0.9)[3])"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"further-customization","dir":"","previous_headings":"","what":"Further customization","title":"Dynamic Spectrogram Visualizations","text":"argument ‘spectro.call’ allows insert customized spectrogram visualizations. instance, following code makes use color_spectro() function warbleR highlight vocalizations male female house wrens different colors (downloading selection table sound file figshare): male part shown green female part yellow. can wrap color_spectro() call using call() function form base R input scrolling_spectro() using argument ‘spectro.call’: option can mixed customizations function, adding oscillogram: viridis color palette: simply gray scale: ‘spectro.call’ argument can also used add annotations. need wrap spectrogram function annotation functions (.e. text(), lines()) single function save call function: Finally, argument ‘annotation.call’ can used add static labels (.e. non-scrolling). works similar ‘spectro.call’, requires call text(). let users customize things size, color, position, font, additional arguments taken text(). call also include argmuents ‘start’ ‘end’ indicate time labels displayed (s). ‘fading’ optional allows fade-fade-effects labels (s well). following code downloads recording containing several frog species recorded Costa Rica figshare, cuts clip including two species labels single label: argument accepts one labels regular text() call. case ‘start’ ‘end’ values supplied label:","code":"# get house wren male female duet recording hs_wren <- read_wave(\"https://ndownloader.figshare.com/files/22722101\") # and extended selection table st <- read.csv(\"https://ndownloader.figshare.com/files/22722404\") # create color column st$colors <- c(\"green\", \"yellow\") # highlight selections color.spectro(wave = hs_wren, wl = 200, ovlp = 95, flim = c(1, 13), collevels = seq(-55, 0, 5), dB = \"B\", X = st, col.clm = \"colors\", base.col = \"black\", t.mar = 0.07, f.mar = 0.1, strength = 3, interactive = NULL, bg.col = \"black\") # save call sp_cl <- call(\"color.spectro\", wave = hs_wren, wl = 200, ovlp = 95, flim = c(1, 13), collevels = seq(-55, 0, 5), strength = 3, dB = \"B\", X = st, col.clm = \"colors\", base.col = \"black\", t.mar = 0.07, f.mar = 0.1, interactive = NULL, bg.col = \"black\") # create dynamic spectrogram scrolling_spectro(wave = hs_wren, wl = 512, t.display = 1.2, pal = reverse.gray.colors.1, grid = FALSE, flim = c(1, 13), loop = 3, width = 1000, height = 500, res = 120, collevels = seq(-100, 0, 1), spectro.call = sp_cl, fps = 60, file.name = \"yellow_and_green.mp4\") # create dynamic spectrogram scrolling_spectro(wave = hs_wren, wl = 512, osc = TRUE, t.display = 1.2, pal = reverse.gray.colors.1, grid = FALSE, flim = c(1, 13), loop = 3, width = 1000, height = 500, res = 120, collevels = seq(-100, 0, 1), spectro.call = sp_cl, fps = 60, file.name = \"yellow_and_green_oscillo.mp4\") st$colors <- viridis(10)[c(3, 8)] sp_cl <- call(\"color.spectro\", wave = hs_wren, wl = 200, ovlp = 95, flim = c(1, 13), collevels = seq(-55, 0, 5), dB = \"B\", X = st, col.clm = \"colors\", base.col = \"white\", t.mar = 0.07, f.mar = 0.1, strength = 3, interactive = NULL) # create dynamic spectrogram scrolling_spectro(wave = hs_wren, wl = 200, osc = TRUE, t.display = 1.2, pal = reverse.gray.colors.1, grid = FALSE, flim = c(1, 13), loop = 3, width = 1000, height = 500, res = 120, collevels = seq(-100, 0, 1), colwave = viridis(10)[c(9)], spectro.call = sp_cl, fps = 60, file.name = \"viridis.mp4\") st$colors <- c(\"gray\", \"gray49\") sp_cl <- call(\"color.spectro\", wave = hs_wren, wl = 200, ovlp = 95, flim = c(1, 13), collevels = seq(-55, 0, 5), dB = \"B\", X = st, col.clm = \"colors\", base.col = \"white\", t.mar = 0.07, f.mar = 0.1, strength = 3, interactive = NULL) # create dynamic spectrogram scrolling_spectro(wave = hs_wren, wl = 512, osc = TRUE, t.display = 1.2, pal = reverse.gray.colors.1, grid = FALSE, flim = c(1, 13), loop = 3, width = 1000, height = 500, res = 120, collevels = seq(-100, 0, 1), spectro.call = sp_cl, fps = 60, file.name = \"gray.mp4\") # create color column st$colors <- viridis(10)[c(3, 8)] # create label column st$labels <- c(\"male\", \"female\") # shrink end of second selection (purely aesthetics) st$end[2] <- 3.87 # function to highlight selections ann_fun <- function(wave, X){ # print spectrogram color.spectro(wave = wave, wl = 200, ovlp = 95, flim = c(1, 18.6), collevels = seq(-55, 0, 5), dB = \"B\", X = X, col.clm = \"colors\", base.col = \"white\", t.mar = 0.07, f.mar = 0.1, strength = 3, interactive = NULL) # annotate each selection in X for(e in 1:nrow(X)){ # label text(x = X$start[e] + ((X$end[e] - X$start[e]) / 2), y = 16.5, labels = X$labels[e], cex = 3.3, col = adjustcolor(X$colors[e], 0.6)) # line lines(x = c(X$start[e], X$end[e]), y = c(14.5, 14.5), lwd = 6, col = adjustcolor(\"gray50\", 0.3)) } } # save call ann_cl <- call(\"ann_fun\", wave = hs_wren, X = st) # create annotated dynamic spectrogram scrolling_spectro(wave = hs_wren, wl = 200, t.display = 1.2, grid = FALSE, flim = c(1, 18.6), loop = 3, width = 1000, height = 500, res = 200, collevels = seq(-100, 0, 1), speed = 0.5, spectro.call = ann_cl, fps = 120, file.name = \"../viridis_annotated.mp4\") # read data from figshare frogs <- read_wave(\"https://ndownloader.figshare.com/files/22829075\") # cut a couple of species shrt_frgs <- cutw(frogs, from = 35.3, to = 50.5, output = \"Wave\") # make annotation call ann_cll <- call(\"text\", x = 0.25, y = 0.87, labels = \"Frog calls\", cex = 1, start = 0.2, end = 14, col = \"#FFEA46CC\", font = 3, fading = 0.6) # create dynamic spectro scrolling_spectro(wave = shrt_frgs, wl = 512, ovlp = 95, t.display = 1.1, pal = cividis, grid = FALSE, flim = c(0, 5.5), loop = 3, width = 1200, height = 550, res = 200, collevels = seq(-40, 0, 5), lcol = \"#FFFFFFCC\", colbg = \"black\", fps = 60, file.name = \"../frogs.mp4\", osc = TRUE, height.prop = c(3, 1), colwave = \"#31688E\", lty = 3, annotation.call = ann_cll) # make annotation call for 2 annotations ann_cll <- call(\"text\", x = 0.25, y = 0.87, labels = c(\"Dendropsophus ebraccatus\", \"Eleutherodactylus coqui\"), cex = 1, start = c(0.4, 7), end = c(5.5, 14.8), col = \"#FFEA46CC\", font = 3, fading = 0.6) # create dynamic spectro scrolling_spectro(wave = shrt_frgs, wl = 512, ovlp = 95, t.display = 1.1, pal = cividis, grid = FALSE, flim = c(0, 5.5), loop = 3, width = 1200, height = 550, res = 200, collevels = seq(-40, 0, 5), lcol = \"#FFFFFFCC\", colbg = \"black\", fps = 60, file.name = \"../frogs_sp_labels.mp4\", osc = TRUE, height.prop = c(3, 1),colwave = \"#31688E\", lty = 3, annotation.call = ann_cll)"},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"workflow","dir":"","previous_headings":"","what":"Workflow","title":"Dynamic Spectrogram Visualizations","text":"Tweak spectrogram settings using prep_static_ggspectro() function – aka prepStaticSpec() – storing results variable. can also just segment export static specs step. exporting PNG testSpec() ggplot function; Import PNG new ggplot raster layer Overlay series translucent highlight boxes disolve away using gganimate","code":"#list WAVs included with dynaSpec (f<-system.file(package=\"dynaSpec\") |> list.files(pattern=\".wav\",full.names=T)) #store output and save spectrogram to working directory params <-prep_static_ggspectro(f[1],destFolder=\"wd\",savePNG=T)"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"static-spectrogram-of-a-female-barn-swallow-song","dir":"","previous_headings":"","what":"Static spectrogram of a female barn swallow song","title":"Dynamic Spectrogram Visualizations","text":"Static Spectrogram female barn swallow song Static spectrogram axis labels female barn swallow song","code":"#let's add axes femaleBarnSwallow<-prep_static_ggspectro(f[1],destFolder=tempdir(),savePNG=T,onlyPlotSpec = F) #Now generate a dynamic spectrogram paged_spectro(femaleBarnSwallow)"},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"now-brighten-the-spec-using-the-amptrans-parameter","dir":"","previous_headings":"","what":"Now brighten the spec using the ampTrans parameter","title":"Dynamic Spectrogram Visualizations","text":"ampTrans=3 nonlinear signal booster. Basically collapses difference loudest quietest values (higher values= brighter specs); 1 (default) means transformation , also lowered decibel threshold include quieter sounds min_dB=-35; default -30 bgFlood=T makes axis area color plot background. automatically switch white axis font background dark. generate dynamic spectrogram Static spectrogram axis labels female barn swallow song","code":"#note that prep_static_spectro() is tha same as prepStaticSpec() #Also paged_spectro() is the same as pagedSpec() p2<-prepStaticSpec(f[1],min_dB=-35, savePNG=T, destFolder=\"wd\",onlyPlotSpec=F,bgFlood=T,ampTrans=3) pagedSpec(p2)"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"now-also-supports-mp3-files-web-or-local-and-multi-page-dynamic-spectrograms-ie-cropping-and-segmenting-spectrograms-from-larger-recording-files","dir":"","previous_headings":"","what":"Now also supports .mp3 files (web or local) and multi-page dynamic spectrograms (i.e. cropping and segmenting spectrograms from larger recording files)","title":"Dynamic Spectrogram Visualizations","text":"default plot axes labels (onlyPlotSpec=T) crop=12 interpreted : use first 12 seconds file; can also specify interval w/ c(0,12) xLim=3 specifies “page window” .e. many seconds “page” dynamic spectrogram display, 3 sec also limit yLim plot vocalized frequencies 0 700 Hz (0.7 kHz)","code":"whale<-prepStaticSpec(\"http://www.oceanmammalinst.org/songs/hmpback3.wav\", savePNG=T,destFolder=\"wd\",yLim=c(0,.7),crop=12,xLim=3,ampTrans=3) pagedSpec(whale) #Voila 🐋"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"static-whale-song-spectrogram","dir":"","previous_headings":"","what":"Static whale song spectrogram","title":"Dynamic Spectrogram Visualizations","text":"Humpback whale song spectrogram","code":""},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"example-using-xeno-canto-to-generate-a-multi-page-dynamic-spectrogram-of-a-common-nighthawk-call-w-different-color-scheme","dir":"","previous_headings":"","what":"Example using Xeno-Canto to generate a multi-page dynamic spectrogram of a common nighthawk call (w/ different color scheme)","title":"Dynamic Spectrogram Visualizations","text":"","code":"song=\"https://www.xeno-canto.org/sounds/uploaded/SPMWIWZKKC/XC490771-190804_1428_CONI.mp3\" temp=prepStaticSpec(song,crop=20,xLim=4,colPal = c(\"white\",\"black\")) pagedSpec(temp,vidName=\"nightHawk\" ,highlightCol = \"#d1b0ff\",cursorCol = \"#7817ff\")"},{"path":"https://marce10.github.io/dynaSpec/index.html","id":"nighthawk-multipage-dynamic-spec","dir":"","previous_headings":"","what":"Nighthawk multipage dynamic spec","title":"Dynamic Spectrogram Visualizations","text":"Enjoy! Please share specs us Twitter! @M_Araya_Salas & @mattwilkinsbio Please cite dynaSpec follows: Araya-Salas, Marcelo Wilkins, Matthew R. (2020), dynaSpec: dynamic spectrogram visualizations R. R package version 1.0.0.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/canyon_wren.html","id":null,"dir":"Reference","previous_headings":"","what":"Acoustic recording of a Catherpes mexicanus (canyon wren) song. — canyon_wren","title":"Acoustic recording of a Catherpes mexicanus (canyon wren) song. — canyon_wren","text":"Acoustic recording Catherpes mexicanus (canyon wren) song.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/canyon_wren.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Acoustic recording of a Catherpes mexicanus (canyon wren) song. — canyon_wren","text":"","code":"data(canyon_wren)"},{"path":"https://marce10.github.io/dynaSpec/reference/canyon_wren.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Acoustic recording of a Catherpes mexicanus (canyon wren) song. — canyon_wren","text":"One Wave object: canyon_wren Catherpes mexicanus recording","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":null,"dir":"Reference","previous_headings":"","what":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"function works object generated prep_static_ggspectro, alias prepStaticSpec(). Video generation time consuming, desired spectrogram parameters set prep step. output mp4 video dynamic spectrogram video. input sound file segmented prep step, resulting video concatenation multiple dynamic spectrogram \"pages.\" page sliding window revealing part static spectrogram played. Temporal width page defined xLim parameter prep_static_ggspectro. can also output temporary segmented files, desired.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"","code":"paged_spectro( specParams, destFolder, vidName, framerate = 30, highlightCol = \"#4B0C6BFF\", highlightAlpha = 0.6, cursorCol = \"white\", delete_temp_files = TRUE )"},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"specParams object returned prep_static_ggspectro destFolder destination output video; setting overwrites setting specParams object vidName expects \"FileName\", .mp4 necessary; supplied, named file used prep_static_ggspectro() framerate default, set 30 (currently supported, animate honor setting) highlightCol default \"#4B0C6BFF\" (purple color match default viridis 'inferno' palette) highlightAlpha opacity highlight box; default 0.6 cursorCol Color leading edge highlight box; default \"white\" delete_temp_files Default= TRUE, deletes temporary files (specs & WAV files used create concatenated video)","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"Nothing returned, though progress file save locations output user. Video play rendering.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"Araya-Salas M & Wilkins M R. (2020). *dynaSpec: dynamic spectrogram visualizations R*. R package version 1.0.0.","code":""},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"Matthew R Wilkins (matt@galacticpolymath.com)","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/paged_spectro.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Make a paged dynamic spectrogram similar to spectral display in Adobe Audition — paged_spectro","text":"","code":"if (FALSE) { # \\dontrun{ #show wav files included with dynaSpec f <- list.files(pattern=\".wav\", full.names = TRUE, path = system.file(package=\"dynaSpec\")) femaleBarnSwallow<-prep_static_ggspectro(f[1],destFolder=tempdir(), onlyPlotSpec = FALSE, bgFlood= TRUE) paged_spectro(femaleBarnSwallow,destFolder=tempdir()) maleBarnSwallow<-prep_static_ggspectro(f[2],destFolder=tempdir(), onlyPlotSpec = FALSE, bgFlood= TRUE,min_dB=-40) paged_spectro(femaleBarnSwallow,destFolder=tempdir()) # Make a multipage dynamic spec of a humpback whale song # Note, we're saving PNGs of our specs in the working directory; to add # axis labels, we set onlyPlotSpec to F, and to make the same background # color for the entire figure, we set bgFlood= TRUE; # The yLim is set to only go to 0.7kHz, where the sounds are for these big whales; #also applying an amplitude transform to boost signal. #This is a longer file, so we're taking the first 12 seconds with crop=12 #xLim=3 means each \"page\" will be 3 seconds, so we'll have 4 dynamic spec pages that get combined humpback <- prep_static_ggspectro( \"http://www.oceanmammalinst.org/songs/hmpback3.wav\",destFolder=tempdir(),savePNG= FALSE, onlyPlotSpec=FALSE,bgFlood= TRUE,yLim=c(0,.7),crop=12,xLim=3,ampTrans=3) #to generate multipage dynamic spec (movie), run the following paged_spectro(humpback,destFolder=tempdir()) # see more examples at https://marce10.github.io/dynaSpec/ } # }"},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"Can used generate single segmented static spectrograms. Works standalone, returned object also intended feed paged_spectro. Workflow: 1) use prep_static_ggspectro crop, filter, segment tweak spectrogram parameters; 2) pass settings paged_spectro generate dynamic spectrogram video.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"","code":"prep_static_ggspectro( soundFile, destFolder, outFilename = NULL, savePNG = FALSE, colPal = \"inferno\", crop = NULL, bg = NULL, filter = NULL, xLim = NULL, yLim = c(0, 10), title = NULL, plotLegend = FALSE, onlyPlotSpec = TRUE, ampTrans = 1, resampleRate = 15000, min_dB = -30, wl = 512, ovlp = 90, wn = \"blackman\", specWidth = 9, specHeight = 3, colbins = 30, ampThresh = 0, bgFlood = FALSE, fontAndAxisCol = NULL, optim = NULL, ... )"},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"soundFile work URLs, full relative paths; handles .mp3 .wav destFolder path directory save output. Needs like \"figures/spectrograms/\" relative working directory. Default=parent folder soundFile. Specify \"wd\" output working directory, gotten [get_wd()] outFilename name output PNG. default=NULL use input name output filename. savePNG logical; Save static spectrograms PNGs? exported destFolder. colPal color palette; one \"viridis\",\"magma\",\"plasma\",\"inferno\",\"cividis\" viridis package 2 value vector (e.g. c(\"white\",\"black\")), defining start end custom color gradient crop subset recording include; default crop=NULL use whole file, 10 sec; number, interpreted crop first X.X sec; c(X1,X2), interpreted trimming specific time interval sec; crop=FALSE, crop , even recordings 10 sec. bg background color (defaults 1st value chosen palette) filter apply bandpass filter? Defaults none (NULL). Expects 'c(0,2)' sound 0 2kHz filtered xLim time limit (x-axis width) seconds spectrograms; .e. page width seconds multi-page dynamic spectrograms (defaults WAV file length, unless file duration >5s). override 5s limit, put xLim=Inf specify desired spectrogram x-axis limit. yLim frequency limits (y-axis); default c(0,10) aka 0-10kHz title string title plots; default=NULL plotLegend logical; include legend showing amplitude colors? default=FALSE onlyPlotSpec logical; want just plot spec leave legend, axes, axis labels? default= TRUE ampTrans amplitude transform boosting spectrum contrast; default=1 (actual dB values); specify decimal number lambda value scales::modulus_trans(); 2.5 good place start. (amplifies loud values , increasing background noise much ) resampleRate number Hz downsample audio spectrogram . simplify audio data speed generation spectrogram. Passed [tuneR::downsample()]. Default=15000 shaves seconds without losing much quality. Put NULL keep original sample rate spectrogram. Audiofile resampled MP4. min_dB minimum decibel (quietest sound) include spec; defaults -30 (-40 include quieter sounds; -20 cut loud sounds) wl window length spectrogram (low values= higher temporal res; high values= higher freq. res). Default 512 good tradeoff; human speech look better 1024 higher, giving higher frequency resolution. ovlp much overlap (percent) sliding windows generate spec? Default 90 looks good, takes longer wn window name (slight tweaks algorithm affect smoothness output) see spectro specWidth width (inches) like make PNG output , saving static spec? specHeight height (inches) like make PNG output , saving static spec? colbins default 30: increasing can smooth color contours, take longer generate spec ampThresh amplitude threshold percent cut recording (try 5 start); default= filtering (high data loss ; recommended; play min_dB ampTrans first) bgFlood want background color spill axis margins? Default=FALSE (.e. white margins) fontAndAxisCol color legend text onlyPlotSpec=TRUE (since margins white, black text); bgFlood=TRUE, color axis margins, labels legend text. supply , picked automatically white black based supplied bg color optim NULL default; experimental feature simplify dataframe FFT-processed waveform used generate spectrogram (currently nothing) ... arguments passed rendering spec (.e. seewave::spectro)","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"list spectrogram parameters, segmented WAV files (segWavs) spectrograms spec; importantly, spec list n=number \"pages\"/segments; first page displayed default","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"Araya-Salas M & Wilkins M R. (2020). *dynaSpec: dynamic spectrogram visualizations R*. R package version 1.0.0.","code":""},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/reference/prep_static_ggspectro.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Generate ggplot2-based spectrogram(s), which can be passed to paged_spectro — prep_static_ggspectro","text":"Matthew R Wilkins (matt@galacticpolymath.com)","code":""},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":null,"dir":"Reference","previous_headings":"","what":"Create scrolling dynamic spectrograms — scrolling_spectro","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"scrolling_spectro create videos single row spectrograms scrolling right left sync'ed sound.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"","code":"scrolling_spectro(wave, file.name = \"scroll.spectro.mp4\", hop.size = 11.6, wl = NULL, ovlp = 70, flim = NULL, pal = seewave::reverse.gray.colors.1, speed = 1, fps = 50, t.display = 1.5, fix.time = TRUE, res = 70, width = 700, height = 400, parallel = 1, pb = TRUE, play = TRUE, loop = 1, lcol = \"#07889B99\", lty = 2, lwd = 2, axis.type = \"standard\", buffer = 1, ggspectro = FALSE, lower.spectro = TRUE, height.prop = c(5, 1), derivative = FALSE, osc = FALSE, colwave = \"black\", colbg = \"white\", spectro.call = NULL, annotation.call = NULL, ...)"},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"wave object class 'Wave'. file.name Character string name output video file. Must include .mp4 extension. Default 'scroll.spectro.mp4'. hop.size numeric vector length 1 specifying time window duration (ms). Default 11.6 ms, equivalent 512 wl 44.1 kHz sampling rate. Ignored 'wl' supplied. wl numeric vector length 1 specifying window length spectrogram, default NULL. supplied, 'hop.size' ignored. ovlp Numeric vector length 1 specifying percent overlap two consecutive windows, spectro. Default 70. flim numeric vector length 2 specifying limits frequency axis (kHz). Default NULL (means 0 Nyquist frequency). pal Character string color palette used. Default 'reverse.gray.colors.1'. speed Numeric vector length 1 indicating speed sound file reproduced (default 1, normal speed). Values < 1 (higher 0) slow values > 1 speed . Note changes speed achieved modifying number frames per second output video. Hence, may want adjust 'fps' video quality considerably affected. fps Numeric vector length 1 specifying number frames per second. t.display Numeric vector length 1 specifying time range displayed spectrogram. fix.time Logical argument control time axis moves along spectrogram remains fixed. Default TRUE (fixed). res Numeric vector length 1 specifying resolution image files (see png). width Numeric vector length 1 specifying width video frame pixels (see png). Default 700. height Numeric vector length 1 specifying height video frame pixels (see png). Default 400. parallel Numeric vector length 1. Controls whether parallel computing applied specifying number cores used. Default 1 (.e. parallel computing). pb Logical argument control progress bar shown. Default TRUE. play Logical argument control video played generated. Default TRUE. loop Logical argument control video formatted played loop (.e. ends start clip). lcol Character string color used vertical line sounds played. Default \"#07889B99\". lty Character string control type line sounds played. Line types can either specified integer (0=blank, 1=solid (default), 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash) one character strings \"blank\", \"solid\", \"dashed\", \"dotted\", \"dotdash\", \"longdash\", \"twodash\", \"blank\" uses 'invisible lines' (.e., draw ).Default 2. lwd Character string control width line sounds played. Default 2. axis.type Character string control style spectrogram axes. Currently 3 options: standard: Y X axes printed default spectro view. minimal: Single lines used denote range defined 1 s 1 kHz X Y axes respectively. none: axis printed (also removes ticks, tick labels, axis labels). buffer Numeric vector length 1 (> 0) specifying time delay start spectrogram scrolling (seconds). Default 1. available loop > 1. ggspectro Logical argument control ggspectro (ggspectro) used instead. Note much less control display parameters ggpsectro = TRUE. Default FALSE. lower.spectro Logical argument control spectrogram full wave object plotted bottom graph. Default TRUE. height.prop Numeric vector length 2 control relative height scrolling lower spectro, respectively. Default c(5, 1). Ignored lower.spectro = FALSE. derivative Logical argument control spectral derivative used instead spectrogram (Sound Analysis Pro, see deriche). Default FALSE. osc Logical argument control oscillogram plotted bottom spectrogram. Default FALSE. Note 'osc' 'lower.spectro' mutually exclusive. colwave Character string control color oscillogram. Default 'black'. colbg Character string control background color. Default 'white'. spectro.call call spectrogram creating function (.e. spectro, color_spectro) generated function call. call replace internal spectrogram creating call. Default NULL. annotation.call call text generated function call. call also include argmuents 'start' 'end' indicate time labels displayed (s).'fading' optional allows fade-fade-effects labels (s well). position ('x' 'y' arguments) 0 1: x = 0, y = 0 corresponds bottom left x = 1, y = 1 corresponds top right position. ... Additional arguments passed spectro customizing spectrograms. Note 'scale' included.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"video file mp4 format working directory scrolling spectrogram.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"function creates videos (mp4 format) single row spectrograms scrolling right left. audio sync'ed spectrograms. Sound files sampling rate 44.1 kHz resampled 44.1 kHz required ffmpeg embeding audio video files.","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"Araya-Salas M & Wilkins M R. (2020). dynaSpec: dynamic spectrogram visualizations R. R package version 1.0.0.","code":""},{"path":[]},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"Marcelo Araya-Salas (marcelo.araya@ucr.ac.cr)","code":""},{"path":"https://marce10.github.io/dynaSpec/reference/scrolling_spectro.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create scrolling dynamic spectrograms — scrolling_spectro","text":"","code":"if (FALSE) { # \\dontrun{ # load example data data(list = c(\"Phae.long1\")) # run function scrolling_spectro(wave = Phae.long1, wl = 300, ovlp = 90, fps = 50, t.display = 1.5, collevels = seq(-40, 0, 5), pal = reverse.heat.colors, grid = FALSE, flim = c(1, 10), res = 120) } # }"},{"path":"https://marce10.github.io/dynaSpec/news/index.html","id":"dynaspec-102","dir":"Changelog","previous_headings":"","what":"dynaSpec 1.0.2","title":"dynaSpec 1.0.2","text":"Fix logic crop xLim prep_static_ggspectro() fixes predictable behavior exported MP4 videos using “Matt’s approach” paged_spectro() Added title parameter add title static subsequent paged spectrogram (MP4) Added resampleRate parameter prep_static_ggspectro() control resolution spectrogram (speed things )","code":""},{"path":"https://marce10.github.io/dynaSpec/news/index.html","id":"dynaspec-101","dir":"Changelog","previous_headings":"","what":"dynaSpec 1.0.1","title":"dynaSpec 1.0.1","text":"CRAN release: 2021-03-09 Fix resampling issue sampling rate waves != 44.1 kHz Fix closing clusters OS != windows","code":""},{"path":"https://marce10.github.io/dynaSpec/news/index.html","id":"dynaspec-100","dir":"Changelog","previous_headings":"","what":"dynaSpec 1.0.0","title":"dynaSpec 1.0.0","text":"CRAN release: 2020-06-22 First release","code":""}]
Araya-Salas M (2024). dynaSpec: Dynamic Spectrogram Visualizations. -R package version 1.0.3, https://github.com/maRce10/dynaSpec. +R package version 1.0.2, https://github.com/maRce10/dynaSpec.
@Manual{, title = {dynaSpec: Dynamic Spectrogram Visualizations}, author = {Marcelo Araya-Salas}, year = {2024}, - note = {R package version 1.0.3}, + note = {R package version 1.0.2}, url = {https://github.com/maRce10/dynaSpec}, }
Installation of external dependencies can be tricky on operating systems other than Linux. An alternative option is to run the package through google colab. This colab notebook explain how to do this step-by-step.
Installation of external dependencies can be tricky on operating systems other than Linux. An alternative option is to run the package through google colab. This colab notebook explain how to do that step-by-step.
Black and white spectrogram:
A spectrogram with black background (colbg = “black”):
Slow down to 1/2 speed (speed = 0.5) with a oscillogram at the bottom (osc = TRUE):
Long-billed hermit song at 1/5 speed (speed = 0.5), removing axes and looping 3 times (loop = 3:
Visualizing a northern nightingale wren recording from xeno-canto using a custom color palette:
Spix’s disc-winged bat inquiry call slow down (speed = 0.05):
This option can be mixed with any of the other customizations in the function, as adding an oscillogram:
A viridis color palette:
Or simply a gray scale:
The ‘spectro.call’ argument can also be used to add annotations. To do this we need to wrap up both the spectrogram function and the annotation functions (i.e. text(), lines()) in a single function and then save the call to that function:
text()
lines()
Finally, the argument ‘annotation.call’ can be used to add static labels (i.e. non-scrolling). It works similar to ‘spectro.call’, but requires a call from text(). This let users customize things as size, color, position, font, and additional arguments taken by text(). The call should also include the argmuents ‘start’ and ‘end’ to indicate the time at which the labels are displayed (in s). ‘fading’ is optional and allows fade-in and fade-out effects on labels (in s as well). The following code downloads a recording containing several frog species recorded in Costa Rica from figshare, cuts a clip including two species and labels it with a single label:
The argument accepts more than one labels as in a regular text() call. In that case ‘start’ and ‘end’ values should be supplied for each label:
#list WAVs included with dynaSpec -(f<-system.file(package="dynaSpec") %>% list.files(pattern=".wav",full.names=T)) +(f<-system.file(package="dynaSpec") |> list.files(pattern=".wav",full.names=T)) #store output and save spectrogram to working directory params <-prep_static_ggspectro(f[1],destFolder="wd",savePNG=T)
Enjoy! Please share your specs with us on Twitter! @M_Araya_Salas & @mattwilkinsbio