#description - calculates the transmission loss from geometric
#spreading, either spherical or cylindrical calculateddB drop
#
#' Calculate pressure drop for spherical spreading.
#'
#' 6 dB per distance doubled. Defaults to dB units, but Pa can be used
#'
#' @param distance distance between source and receiver
#' @param initlevel sound level at source
#' @param unit units of dB or Pa
#' @export
#' @examples
#' pressuredrop(2)
#' 6
#'
#' pressuredrop(2, 100, unit = "Pa")
#'$Transmissionloss
#'[1] 0.5
#'
#'$newlevel
#'[1] 50
pressure_transmissionloss<- function(distance = 4, initlevel = 100, unit = "dB"){
if (unit == "dB"){
TL<- 20*log(distance, base = 10)
newlevel<-initlevel-TL
my_list <- list("Transmission loss_dB" = TL,
"newlevel" = newlevel)
}
else if (unit == "Pa"){
TL<- 1/distance
newlevel<-initlevel*TL
my_list <- list("Transmission loss_Pa(proportion)" = TL, "newlevel" = newlevel)
}
else{
return("Please specify unit")
}
return(my_list)
}
#pressure_transmissionloss()
#pressure_transmissionloss(unit = "Pa")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.