Learn R Programming

PAMmisc (version 1.12.4)

writeClickWave: Write Click Waveform

Description

Write a wave file for a synthesized delphinid click

Usage

writeClickWave(
  fileName,
  outDir,
  signalLength,
  clickLength,
  clicksPerSecond,
  frequency,
  sampleRate,
  silence = c(0, 0),
  gainFactor = 0.1
)

createClickWave( signalLength, clickLength, clicksPerSecond, frequency, sampleRate, silence = c(0, 0), gainFactor = 0.1 )

Value

writeClickWave invisibly returns the file name, createClickWave

returns a Wave class object

Arguments

fileName

name of the file to write. If missing, the file be named usign signalLength, clickLength, clicksPerSecond, frequency, and sampleRate

outDir

directory to write wave files to

signalLength

length of signal to create in seconds

clickLength

length of each click in microseconds

clicksPerSecond

number of clicks per second

frequency

frequency of the clicks

sampleRate

sample rate for the wave file to create

silence

silence to pad before and after signal in seconds

gainFactor

scaling factor between 0 and 1. Low numbers are recommended (default 0.1)

Author

Taiki Sakai taiki.sakai@noaa.gov

Details

This code is based on Matlab code by Julie Oswald (2004). Clicks are simulated as an exponentially damped sinusoid.

Examples

Run this code

tmpFile <- file.path(tempdir(), 'tempWav.wav')
writeClickWave(tmpFile, signalLength = 1, clickLength = 100, clicksPerSecond = 200,
               frequency = 30000, sampleRate = 100000)
file.remove(tmpFile)
clickWave <- createClickWave(signalLength = 1, clickLength = 100, clicksPerSecond = 200,
                             frequency = 30e3, sampleRate = 100e3)

Run the code above in your browser using DataLab