[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: functions for audio
From: |
Paul Kienzle |
Subject: |
Re: functions for audio |
Date: |
Mon, 4 Jun 2001 10:31:37 +0100 |
User-agent: |
Mutt/1.2.5i |
On Mon, Jun 04, 2001 at 12:26:19AM -0700, Aaron Brick wrote:
> hello dave,
>
> thanks a lot for your rapid reply! :)
>
> so, to create a CD-quality one-second sample of middle A:
>
> fs=44100
> freq=440
> saveaudio ("file", sin ( (2*pi) * (freq/fs) * (1:fs) ), "au", 16)
>
> and then:
>
> sox -r 44100 -t ul file.au file.wav
> play file.wav
>
> the samples come out super-quiet; i multiplied the sine function by about
> 100 to solve this.
Looking at the source for saveaudio, it is expecting numbers in the
range -128:127 or -32768:32767. You should be multiplying by 127.
Alternatively, you could use my ausave function which uses an audio
range -1:1, and allows you to save a .wav file directly. See
the octave project on sourceforge:
http://cvs.sf.net/cgi-bin/viewcvs.cgi/octave/octave/scripts/nonnumeric/audio/
>
> now for a more complex sound which i'm stuck trying to create. i'm
> having conceptual difficulties translating my mathematical ideas into the
> sine ( constants * range ) form that octave uses.
>
> i'm used to sound wave equations looking like y = A * sine ( F * x ), where
> A is an adjustment in amplitude, and F in frequency. i want a sound whose
> amplitude increases over time; normally i would define it by setting A =
> (1.01)^x. i don't know syntactically how to do this in octave.
(1.01).^x, where x is a vector.
To get a frequency varying like F(x), you will need to do something like:
x = 0:1/fs:tmax;
y = cos(cumsum(F(x))/fs);
E.g., the following has a frequency which varies sinusoidally:
function p=F(x), p = 5000*(sin(2*pi*x)+1); end
tmax=2;
fs = 1000;
y = cos(cumsum(F(x))/fs);
imagesc(flipud(stft(y)));
>
> and do you know how to calculate nth roots? i can't find any mention of them
> in the manual.
a^(1/n)
>
> many thanks,
>
> aaron.
>
Paul Kienzle
address@hidden
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------