Replay Audio Spectrum of Time Series


I’m not sure if this is possible with audacity but any help will be highly appreciated.

I have a sound spectra data on 1/3 octave bands from 50 Hz to 8kHz. It’s a tabular text data over time vs frequency. Each band sound levels are expressed in dB’s.

The data is a time series and each spectra is recorded for 100ms intervals. (For the curious mind it’s a sound level measurement data)

I’m wondering if or how I can generate or play sound from such sound spectrum over time. All sound or tone generators I’ve found creates pure tones with constant or limited time changes.

I don’t need a high quality sound output. It will be enough if I could get a general idea of the sound when I play it mostly to spot the changes over time so that I can get rid of the unwanted sound intervals easier.

Thanks in advance.

So have I got this right?

What you want to do is synthesize 22 bands of 1/3 octave band limited noise. Each band is amplitude modulated according to the number in your table.

If that is along the right lines, then there isn’t an existing effect for that and there are a number of conceptual problems to overcome, but it may be possible to write a Nyquist script to do something along those lines.

What is this about?

Thanks for the answer Steve.

That’s exactly what I want. (Just to be exact 23 1/3 octave band levels)

Steve I’m recording environmental noise. So the data is logged in such manner. Some devices can’t record audio, some takes too much storage so I’m looking for an alternative solution.

I’ll look into those plugins. I hope I manage to make some noise.

One of the “conceptual problems” that I mentioned is that it’s impossible to create constant amplitude narrow band noise.
If you take white noise as an example, by definition the noise is random, though the average amplitude is constant across all frequencies within the audio spectrum. If you look at a broad band of noise the amplitude appears to be fairly constant, but as you narrow the bandwidth the amplitude becomes increasingly erratic. This is a pretty major problem for your project because it’s impossible to control the short term amplitude of random noise (because it is random).

A possible workaround for this would be to use 33 sine waves rather than noise.
If you think about “normal” white light, it contains millions of different frequencies, much like white noise. Now consider white light from fluorescent tube lamps. These types of lamp produce relatively few distinct frequencies, but because they are distributed fairly evenly though the visible spectrum, the combined effect is still white light, and the colours of objects seen in that light still appear to be quite natural, even though there are a relatively tiny number of frequencies. A similar thing happens with sound. Intelligible speech can be synthesized using just a handful of sine wave frequencies. In your experiment you would have 33 frequencies with which it should be possible to create meaningful results.

A single frequency can be created using the function (hzosc freq)
where “freq” is the frequency that you wish to generate. For example, to create a frequency of 440 Hz you can use:

(hzosc 440)

You can try this out by creating an empty audio track, selecting part of it, then open the “Nyquist Prompt” effect (in the “Effect” menu) and entering that code into the text box. When you click the OK button a 440 Hz tone will be generated that fills the selection.

By default the amplitude will be 0 dB (+1 to -1).
The amplitude can be adjusted by multiplying the waveform by a value using the function mult, for example this code will produce a 1000 Hz sine wave with an amplitude scaled down to +0.5 to -0.5 (-6 dB)

(mult 0.5 (hzosc 1000))

To create multiple tones at the same time, generated tones can be added together using sim. For example, to create a sound that contains the frequencies 100 Hz, 200 Hz, 400 Hz and 800 Hz, all at amplitude 0.1, the following code will work:

  (scale 0.1 (hzosc 100))
  (scale 0.1 (hzosc 200))
  (scale 0.1 (hzosc 400))
  (scale 0.1 (hzosc 800)))

Rather than setting the amplitude to a constant level, you want to vary the amplitude. To do this you can create an “envelope” using the functions pwl or pwlv
For example, to create a tone that rises from silence up to 0.5, then stays at 0.5 for a while, then goes up to 1.0 before dropping back down to 0, a suitable envelope can be created with this code:
(pwlv 0.0 0.25 0.5 0.5 0.5 0.75 1.0 1.0 0.0)
By default this is created at a low sample rate so the generated envelope will be much shorter duration than the track selection.
Using this envelope on a generated sine wave:

  (hzosc 440)
  (pwlv 0.0 0.25 0.5 0.5 0.5 0.75 1.0 1.0 0.0))

In order to be able to handle a large number of amplitude points you will need some way of getting the data into Nyquist to create a list of amplitude points so that you can then use pwl-list or pwlv-list to create the complex envelope.

As you see, this is not a simple first project, but I think it is certainly possible.

Thanks a lot Steve. You’ve been really helpful.

I am aware of the missing spectra and my data is not a narrow band one. Also I’m not expecting to create an exact sound from the data.

But even this output will be quite useful for me.

For the data manipulation I’m planning to write an Excel macro so that it will output an Nyquist command.

One last thing though. My data is on an adjusted dB scale. So my values are like 86.7 dB, 76.8 dB, 66.4 dB, …, etc.
So how should I use the PWLV envelope or PWLR-list . Should i find the logarithmic average and than use the logaritmic difference as +/- levels in the envelope file?
Similarly in such case how can I determine the scale factor for different averages of different octave band levels.

Thanks again. Best regards.

relative to what?
In Audacity (and signal processing in general), 0 dB is usually taken relative to full scale. That is, +1 or -1 on the linear scale (top / bottom of the audio track) is 0 dB. All normal audio signals are below this level, so full scale is 0 dB and silence is - infinity dB.

If you can convert the data so that it is relative to full scale, then there is a handy function in Nyquist: (db-to-linear) which converts the dB scale to the linear scale.

That’s true for Audacity, but it sounds (ha!) to me as though ldal is working from audio recordings, perhaps in the field (however you define “field”), so the level are probably Sound Pressure Levels, such as “Vuvuzela horn at 1 m = 120dB.”

At any rate, this is no problem - the first step is to find the highest level in the dataset, then call that Zero Decibels and subtract the other levels from there. For example, if the data set is those three points above…

 86.7 dB, 76.8 dB,  66.4 dB
 => 0 dB, -9.9 dB, -20.3 dB