# HG changeset patch # User stevecassidy # Date 1481155851 18000 # Node ID dbcf9bc275e3856f14f9b6c640e814905b520e6b # Parent 6d6dc275b10722e73123defc2a0d238660eae6c4 planemo upload commit 063e049d569aeb45e1008cbf044f2dad850eca3d-dirty diff -r 6d6dc275b107 -r dbcf9bc275e3 g_cepstrum.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/g_cepstrum.R Wed Dec 07 19:10:51 2016 -0500 @@ -0,0 +1,26 @@ + +library(wrassp) + +args = commandArgs(TRUE) +# args will be like +# ${wavfile} ${output} +# ${beginTime} ${endTime} +# ${windowShift} ${window} ${resolution} +# ${fftLength} + + +if (length(args) != 8) { + print("Wrong number of arguments!") + q("no", status=1) +} + +res = cepstrum(args[1], toFile=FALSE, + beginTime=as.numeric(args[3]), + endTime=as.numeric(args[4]), + windowShift=as.numeric(args[5]), + window=args[6], + resolution=as.numeric(args[7]), + fftLength=as.numeric(args[8]) + ) + +assp_to_tsv(res, args[2]) diff -r 6d6dc275b107 -r dbcf9bc275e3 g_cepstrum.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/g_cepstrum.xml Wed Dec 07 19:10:51 2016 -0500 @@ -0,0 +1,67 @@ + + using wrassp + + + R + r-wrassp + + + + r_wrapper.sh $__tool_directory__/g_cepstrum.R --args ${wavfile} ${output} + ${beginTime} ${endTime} ${windowShift} ${window} ${resolution} + ${fftLength} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Short-term cepstral analysis of the signal using the Fast Fourier Transform. The number of coefficients per output record will also equal the FFT length / 2 + 1 (i.e. be non-mirrored). + + + + @Manual{, + title = {wrassp: an R wrapper to the ASSP Library}, + author = {Lasse Bombien and Raphael Winkelmann and Michel + Scheffers}, + year = {2016}, + note = {R package version 0.1.4}, + } + + + diff -r 6d6dc275b107 -r dbcf9bc275e3 g_f0.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/g_f0.R Wed Dec 07 19:10:51 2016 -0500 @@ -0,0 +1,25 @@ + +library(wrassp) + +args = commandArgs(TRUE) +# args will be like +# ${wavfile} ${output} +# ${beginTime} ${endTime} ${windowShift} ${gender} ${maxF} ${minF} ${minAmp} ${maxZCR} + + + +if (length(args) != 10) { + print("Wrong number of arguments!") + q("no", status=1) +} + +res = ksvF0(args[1], toFile=FALSE, beginTime=as.numeric(args[3]), endTime=as.numeric(args[4]), + windowShift=as.numeric(args[5]), + gender=args[6], + maxF=as.numeric(args[7]), + minF=as.numeric(args[8]), + minAmp=as.numeric(args[9]), + maxZCR=as.numeric(args[10]) + ) + +assp_to_tsv(res, args[2]) diff -r 6d6dc275b107 -r dbcf9bc275e3 g_f0.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/g_f0.xml Wed Dec 07 19:10:51 2016 -0500 @@ -0,0 +1,57 @@ + + using wrassp ksvF0 pitch tracker + + + R + r-wrassp + + + + r_wrapper.sh $__tool_directory__/g_f0.R --args ${wavfile} ${output} + ${beginTime} ${endTime} ${windowShift} ${gender} ${maxF} ${minF} ${minAmp} ${maxZCR} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + F0 analysis of the signal using the K. Schaefer-Vincent periodicity detection algortithm. + + + + + @Manual{, + title = {wrassp: an R wrapper to the ASSP Library}, + author = {Lasse Bombien and Raphael Winkelmann and Michel + Scheffers}, + year = {2016}, + note = {R package version 0.1.4}, + } + + + diff -r 6d6dc275b107 -r dbcf9bc275e3 g_forest.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/g_forest.R Wed Dec 07 19:10:51 2016 -0500 @@ -0,0 +1,29 @@ + +library(wrassp) + +args = commandArgs(TRUE) +# args will be like +# ${wavfile} ${output} +# ${beginTime} ${endTime} ${windowShift} ${windowSize} ${effectiveLength} +# ${nominalF1} ${gender} ${estimate} ${order} ${incrOrder} ${numFormants} +# ${window} ${preEmphasis} + + +if (length(args) != 15) { + print("Wrong number of arguments!") + q("no", status=1) +} + +res = forest(args[1], toFile=FALSE, beginTime=as.numeric(args[3]), endTime=as.numeric(args[4]), + windowShift=as.numeric(args[5]), + windowSize=as.numeric(args[6]), + effectiveLength=as.integer(args[7]), + nominalF1=as.numeric(args[8]), + gender=args[9], + estimate=as.integer(args[10]), + order=as.numeric(args[11]), incrOrder=as.numeric(args[12]), + numFormants=as.numeric(args[13]), window=args[14], + preemphasis=as.numeric(args[15]) + ) + +assp_to_tsv(res, args[2]) diff -r 6d6dc275b107 -r dbcf9bc275e3 g_forest.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/g_forest.xml Wed Dec 07 19:10:51 2016 -0500 @@ -0,0 +1,87 @@ + + using wrassp formant tracker + + + R + r-wrassp + + + + r_wrapper.sh $__tool_directory__/g_forest.R --args ${wavfile} ${output} + ${beginTime} ${endTime} ${windowShift} ${windowSize} ${effectiveLength} + ${nominalF1} ${gender} ${estimate} ${order} ${incrOrder} ${numFormants} + ${window} ${preemphasis} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Calculate the formant tracks for segments of an audio file. + Raw resonance frequency and bandwidth values are obtained by root-solving of the Linear Prediction polynomial from the autocorrelation method and the Split-Levinson-Algorithm (SLA). Resonances are then classified as formants using the so-called Pisarenko frequencies (by-product of the SLA) and a formant frequeny range table derived from the nominal F1 frequency. The latter may have to be increased by about 12% for female voices (see NominalF1 and Gender options). + + + + + @Manual{, + title = {wrassp: an R wrapper to the ASSP Library}, + author = {Lasse Bombien and Raphael Winkelmann and Michel + Scheffers}, + year = {2016}, + note = {R package version 0.1.4}, + } + + + diff -r 6d6dc275b107 -r dbcf9bc275e3 get_fm_at_midpoint.xml --- a/get_fm_at_midpoint.xml Mon Aug 15 23:48:20 2016 -0400 +++ b/get_fm_at_midpoint.xml Wed Dec 07 19:10:51 2016 -0500 @@ -1,4 +1,4 @@ - + using wrassp formant tracker diff -r 6d6dc275b107 -r dbcf9bc275e3 outputAssp.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/outputAssp.R Wed Dec 07 19:10:51 2016 -0500 @@ -0,0 +1,37 @@ +assp_to_est <- function(assp, outfile) { + + # convert to a dataframe + result <- data.frame(assp[1]) + for(idx in seq(2,length(attr(assp,'names')))) { + result <- cbind(result, assp[idx]) + } + # add a column of timestamps + start <- attr(assp, 'startTime') + rate <- attr(assp, 'sampleRate') + sampletime <- seq(start, by=1/rate, length.out=nrow(result)) + # and a column of 1s for some reason + #one <- rep(1, nrow(result)) + result <- cbind(sampletime, result) + + # write header + #write("EST_File Track", file=outfile) + #write("DataType ascii", file=outfile, append=T) + #write("BreaksPresent true", file=outfile, append=T) + #write(paste("NumFrames", nrow(result)), file=outfile, append=T) + + #count <- 0 # count overall number of columns + #vcount <- 1 # count variables in assp obj + #for(name in attr(assp,'names')) { + # for (coln in seq(ncol(data.frame(assp[vcount])))) { + # colname = paste(name, coln, sep="_") + # write(c(paste("Channel_", count, " ", colname, sep="")), file=outfile, append=T) + # count <- count+1 + # } + # vcount <- vcount+1 + #} + #write(paste("NumChannels", count), file=outfile, append=T) + #write("EST_Header_End", file=outfile, append=T) + + + write.table(result, file=outfile, sep="\t", quote=F, row.names=F, col.names=T, append=F) +} \ No newline at end of file diff -r 6d6dc275b107 -r dbcf9bc275e3 r_wrapper.sh --- a/r_wrapper.sh Mon Aug 15 23:48:20 2016 -0400 +++ b/r_wrapper.sh Wed Dec 07 19:10:51 2016 -0500 @@ -1,6 +1,6 @@ #!/bin/sh -### Run R providing the R script in $1 as standard input and passing +### Run R providing the R script in $1 as standard input and passing ### the remaining arguments on the command line # Function that writes a message to stderr and exits @@ -11,7 +11,9 @@ } # Ensure R executable is found -which R > /dev/null || fail "'R' is required by this tool but was not found on path" +which R > /dev/null || fail "'R' is required by this tool but was not found on path" + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Extract first argument infile=$1; shift @@ -20,4 +22,5 @@ test -f $infile || fail "R input file '$infile' does not exist" # Invoke R passing file named by first argument to stdin -R --vanilla --slave $* < $infile +# add in the util.R file too containing common functions +cat $DIR/util.R $infile | R --vanilla --slave $* diff -r 6d6dc275b107 -r dbcf9bc275e3 util.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/util.R Wed Dec 07 19:10:51 2016 -0500 @@ -0,0 +1,17 @@ +assp_to_tsv <- function(assp, outfile) { + + # convert to a dataframe, need to add one column at a time + result <- data.frame(assp[1]) + if (length(attr(assp,'names'))>1) { + for(idx in seq(2,length(attr(assp,'names')))) { + result <- cbind(result, assp[idx]) + } + } + # add a column of timestamps + start <- attr(assp, 'startTime') + rate <- attr(assp, 'sampleRate') + time <- seq(start, by=1/rate, length.out=nrow(result)) + result <- cbind(time, result) + + write.table(result, file=outfile, sep="\t", quote=F, row.names=F, col.names=T, append=F) +}