-
Notifications
You must be signed in to change notification settings - Fork 0
/
fm_sweep.Rmd
69 lines (53 loc) · 2.77 KB
/
fm_sweep.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
title: "fm_sweep"
author: "Brian C Leavell"
date: "`r Sys.Date()`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Generating frequency modulated tone for use in ultrasonic propagation study
Goal: Synthesize broad-spectrum, frequency modulated tone as .wav file.
Details: This creates a broad-spectrum, frequency-modulated (fm) tone that is based off the range of echolocation frequencies of species listed in the pdf "WesternUS_Acoustic_Table_Mar2011" by Joe Szewczak, Humboldt State University Bat Lab, June 2018. The fm signal starts at 100 kHz, which is near the upper end of *Myotis californicus*'s call and ends at 10 kHz, which is near the lower end of *Euderma maculatum*'s call. This signal is 2 ms in duration, based off the signal duration used in other echolocation propagation studies (e.g. Goerlitz 2018 and Lawrence and Simmons 1982).
```{r packages}
library(tuneR)
library(seewave)
```
Create file
Settings:
100 kHz to 10 kHz frequency sweep
Sine wave
Fade-in & Fade-out = None
Sample rate = 250 kHz
Bit depth = 16 (PCM)
Duration = 1 second (2 msec signal + 998 msec silence)
```{r fmsweep}
fmsweep <- synth(f = 250000, #sampling freq in Hz
cf = 100000, #carrier frequency in Hz
d = 0.002, #duration in seconds
a = 1, #max intensity
signal = "sine", #type of signal
fm = c(0,0,-90000,0,0), #frequency modulation (max excursion of sinusoidal fm in Hz, freq of fm in Hz, max excursion of linear fm in Hz, phase of fm in radian, max excursion of exponential fm in Hz)
output = "Wave" #object class
)
#fmsweep <- fadew(fmtone, din = 0.010, dout = 0.010, shape = "exp", output = "Wave") # 10 msec fade in and fade out, included here from an earlier version in which the signal was longer in duration
fmsweep <- addsilw(fmsweep, at = "end", d = 0.998, output = "Wave")
savewav(fmsweep, filename = "100to10kHz_fmtone.wav") #final file save as .wav
```
## Oscillogram
``` {r oscillo}
oscillo(fmsweep, from = 0, to =0.002)
```
## Power spectrum
``` {r powerspec}
meanspec(fmsweep, wl = 256, ovlp = 75, from = 0.000, to =0.002)
```
## Spectrogram
``` {r spectrogram}
spectro(fmsweep, wl = 128, ovlp = 75, tlim = c(0.000,0.002))
```
##References
Goerlitz HR. 2018. Weather conditions determine attenuation and speed of sound: Environmental limitations for monitoring and analyzing bat echolocation. Ecol Evol. 8(10):5090–5100. doi:10.1002/ece3.4088.
Lawrence BD, Simmons JA. 1982. Measurements of atmospheric attenuation at ultrasonic frequencies and the significance for echolocation by bats. J Acoust Soc Am. 71(3):585–590. doi:10.1121/1.387529.
"WesternUS_Acoustic_Table_Mar2011" by Joe Szewczak, Humboldt State University Bat Lab, June 2018