Skip to content

Commit

Permalink
fixed error where WAV durations slightly longer than 30sec making a 4…
Browse files Browse the repository at this point in the history
…0sec video
  • Loading branch information
drwilkins committed Sep 20, 2024
1 parent c6b0f52 commit 8fb361c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions R/prep_static_ggspectro.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ prep_static_ggspectro <-
soundFile = soundFile,
destFolder = destFolder,
outFilename = outFilename,
n_pages= length(prepped$segWavs),
crop = crop,
colPal = colPal,
isViridis = isViridis,
Expand Down
8 changes: 4 additions & 4 deletions R/processSound.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ processSound <- function(wav0, filter, ampThresh, crop, xLim, ...) {

# Make wav file match page xlims ------------------------------------------
#Given xLim, what is the full length the recording needs to be?
max_page_dur <- ceiling(wavDur / xLim[2]) * xLim[2]

#Add silence at the end if (user-supplied) xLim>cropped Duration or xLim doesn't divide into even segments of wave duration
max_page_dur <- ceiling( round(wavDur,digits=2) / xLim[2]) * xLim[2]

timeRemainder <-
(max_page_dur - wavDur)
Expand Down Expand Up @@ -140,10 +138,12 @@ processSound <- function(wav0, filter, ampThresh, crop, xLim, ...) {
bit = wav@bit
)
wav <- tuneR::bind(wav, fillerWAV)
}

#pastew results in intermittent problems! Don't use! bind seems much more dependable
#seewave::pastew(wave1=fillerWAV,wave2=wav,at="end",output="Wave",join=T,bit=wav0@bit)
wavDur <- max(length(wav@left), length(wav@right)) / wav@samp.rate
}

#Segment wav or make list of 1 if no segmentation
#The ceiling code here is to deal with e.g. duration of 29.999 and xLim=10 that would only produce 2 segments

Expand Down

0 comments on commit 8fb361c

Please sign in to comment.