Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Saving Audio with Correct Sample Rate

$
0
0

@ambiso wrote:

Hay!

I’m trying to generate and save a very simple 440Hz waveform.

Unfortunately, the generated file does not inherit the 44100Hz sample rate that I assigned.
Instead it has a 8000Hz sample rate:

$ file test.wav
test.wav: RIFF (little-endian) data, WAVE audio, mono 8000 Hz

Here’s the code that I am using:

using SampledSignals
using FileIO
using LibSndFile

sr = 44100 # sample rate
signal = sin.(2π*440*x for x in 0:1/sr:1)
signal = SampleBuf(signal, sr)
@assert samplerate(signal) == sr

save("test.wav", signal)

Could this be an error with the LibSndFile package that I am using?

Kind regards,
ambiso

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles