Praat Spectrum object with direct C++ module binding (complex FFT spectrum). Spectrum objects represent frequency-domain representations of sounds. Uses a shared dispatch table for minimal memory per object.
Query methods
get_lowest_frequency()- lowest frequency (Hz)get_highest_frequency()- highest frequency (Hz)get_number_of_bins()- number of frequency binsget_frequency_step()- frequency step (Hz)get_real_value_in_bin(bin)- real part at a binget_imaginary_value_in_bin(bin)- imaginary part at a binget_frequency_from_bin(bin)- frequency for a bin numberget_bin_from_frequency(freq)- bin number for a frequencyget_band_density(fmin, fmax)- power density in a band (Pa²/Hz²)get_band_energy(fmin, fmax)- energy in a band (Pa²·s)get_centre_of_gravity(power = 2.0)- spectral center of gravityget_standard_deviation(power = 2.0)- spectral standard deviationget_skewness(power = 2.0)- spectral skewnessget_kurtosis(power = 2.0)- spectral kurtosisget_central_moment(moment, power = 2.0)- central moment
Modification methods
pass_hann_band(fmin, fmax, smooth = 100)- apply a Hann band-pass filterstop_hann_band(fmin, fmax, smooth = 100)- apply a Hann band-stop filtercepstral_smoothing(bandwidth)- smooth using the cepstral method
Transform methods
to_sound()- convert to Sound (inverse FFT)to_ltas(bandwidth)- convert to long-term average spectrumto_spectrogram(...)- convert to Spectrogramto_excitation(erb_density)- convert to Excitation (auditory representation)
Export methods
as_matrix()- export as a numeric matrix (real + imaginary)as_data_frame()- export as a data.frame (freq, real, imag, power)save(path)- save to a file
Examples
sound <- Sound$create_tone(duration = 0.5, frequency = 440, sampling_rate =
44100)
spectrum <- sound$to_spectrum(fast = FALSE)
cog <- spectrum$get_centre_of_gravity(power = 2.0)
energy <- spectrum$get_band_energy(fmin = 400, fmax = 500)
# Create a spectrum from a recording read from disk
sound <- Sound(system.file("extdata", "test.wav", package = "pladdrr"))
spectrum <- sound$to_spectrum(fast = TRUE)
spec_df <- spectrum$as_data_frame()