-
Notifications
You must be signed in to change notification settings - Fork 0
/
white_noise_generation.Rmd
59 lines (45 loc) · 1.65 KB
/
white_noise_generation.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
---
title: "white noise generation"
author: "Brian C Leavell"
date: "`r Sys.Date()`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Generating white noise for use in ultrasonic microphone calibration
Goal: Generate broad-spectrum, ultrasonic white noise .wav file.
Why?: Why not? ...To be used for calibration of WildLife Acoustics microphone and Song Meter acoustic recording unit sensitivities.
```{r packages}
library(tuneR)
library(seewave)
```
Create white noise file
Settings:
Butterworth band-pass filter (1-90 kHz pass)
Fade-in & Fade-out = 10 msec
Sample rate = 192 kHz
Bit depth = 16 (PCM)
Duration = 2 seconds
```{r noise}
whitenoise <- noise(kind = "white",
samp.rate = 192000,
bit = 16,
pcm = TRUE,
duration = 2,
xunit = "time") #xunit time defaults to seconds
# oscillo(whitenoise) #oscillogram of unedited white noise
# meanspec(whitenoise, wl = 1024) #spectrogram of unedited white noise
writeWave(whitenoise, filename = "ultrasound_white_noise.wav") #unfiltered/unedited .wav
filtered_whitenoise <- bwfilter(whitenoise, n = 5, from = 1000, to = 90000, bandpass = TRUE, output = "Wave") # band-pass filter
filtered_whitenoise <- fadew(filtered_whitenoise, din = 0.010, dout = 0.010, shape = "exp", output = "Wave") # 10 msec fade in and fade out
savewav(filtered_whitenoise, filename = "1to90kHz_bandpass_ultrasound_white_noise.wav") #final file save as .wav
```
## Oscillogram
``` {r oscillo}
oscillo(filtered_whitenoise)
```
## Power spectrum
``` {r powerspec}
meanspec(filtered_whitenoise, wl = 256)
```