Funciones para analizar sonido (archivos wave) y Espectrograma 3D

#Carpeta de trabajo
setwd("E:/Tensorflow_bird/Cantos")
library(tuneR)
## Warning: package 'tuneR' was built under R version 3.6.1
library(seewave)
## Warning: package 'seewave' was built under R version 3.6.1
library(rgl)
## Warning: package 'rgl' was built under R version 3.6.1

Importando archivo wav

Funcion readWave ()

canto<-readWave(filename = "1154.wav", from = 1)
str(canto)
## Formal class 'Wave' [package "tuneR"] with 6 slots
##   ..@ left     : int [1:220979] 23 20 20 19 21 21 20 18 16 19 ...
##   ..@ right    : int [1:220979] 26 18 18 22 19 24 17 19 16 18 ...
##   ..@ stereo   : logi TRUE
##   ..@ samp.rate: int 44100
##   ..@ bit      : int 16
##   ..@ pcm      : logi TRUE
summary(canto)
## 
## Wave Object
##  Number of Samples:      220979
##  Duration (seconds):     5.01
##  Samplingrate (Hertz):   44100
##  Channels (Mono/Stereo): Stereo
##  PCM (integer format):   TRUE
##  Bit (8/16/24/32/64):    16
## 
## Summary statistics for channel(s):
## 
##       Min. 1st Qu. Median        Mean 3rd Qu. Max.
## left  -296      -3      0 -0.05155241       2  296
## right -298      -3      0 -0.05125374       2  295

Oscilogramas:

1. Graficos - oscilograma del canto

2. Graficos - oscilograma segmentado del canto del comemaiz

3. Graficos -oscilograma traslapado con un “contorno” (envelope)

oscillo(canto,f=22050)

oscillo(canto,f=22050,k=2,j=2,byrow=TRUE)

oscillo(canto,f=22050)
par(new=TRUE)
env(canto,f=22050,colwave=2)

Graficos - frecuencia “instantanea” (usando transformacion de Hilbert).

ifreq(canto,f=22050,threshold=5)

Graficos - espectro completo y espectro promedio (chicharras).

spec(canto,f=22050,type="l")

meanspec(canto,f=22050,wl=512,type="l")

Graficos - Espectrograma.

spectro(canto,f=22050,wl=512,ovlp=50,zp=16,collevels=seq(-100,0,0.5))

## This took quite a lot of time to display this spectrogram, you may set 'fastdisp=TRUE' for a faster, but less accurate, display

Graficos -Espectrograma modificado.

canto2<-cutw(canto,f=22050,from=1,plot=FALSE)
spectro(canto2,f=22050,wl=512,ovlp=85,collevels=seq(-25,0,1),
        osc=TRUE,palette=reverse.heat.colors,colgrid="white", colwave="white",
        colaxis="white",collab="white", colbg="black", fastdisp=TRUE)

Espectrograma 3D

spectro3D(canto,f=22050,wl=512,ovlp=75,zp=16,maga=2)