help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems on audio playing in Octave


From: Ian McCallion
Subject: Re: Problems on audio playing in Octave
Date: Tue, 14 Aug 2018 21:03:23 +0100

Hi Andrea,

Change your portant definition to:

      portante = cos(2*pi*fp*t);

Most of your samples will have been clipped, which is why the
resulting sound is distorted and not representative of the wave.

Cheers... Ian

On 14 August 2018 at 10:24, Andrea M <address@hidden> wrote:
> Hi!
>
> I'm having problems with audio playback in octave, by using the player
> object.
> I'm very new to Octave so probably I'm making mistakes somwhere but I wasn't
> able to understand where.
>
> I'm using a very simple code to generate a cosine wave, then i use the
> player to hear it. The strange thing is that not all the frequency are
> played properly. I mean that if I try to play a wave at 100 Hz or 200 Hz all
> is fine (and so for other values of frequency). But if I try to play a 199
> Hz wave, I get something distorted that sound about 40 Hz, and so happens
> for other frequencies. For another example, I'm not able to play 440 Hz.
> This should not be a problem of sampling because I'm using 8000 Hz sampling
> rate that should work for all frequencies up to 4 kHz.
> I've also tried to plot the wave at 440 Hz and it seems to be correct, so I
> don't know where the problem is. I wonder if there is something wrong when i
> generate the wave or where I initialize the player object.
>
> Net there is the code I'm using:
>
>
> fs1 = 8000;            % sampling rate
> T = 3;                    % wave lenght in seconds
> N = fs1.*T;             % number of samples
> fp = 440;                % wave frequency
> t = (0:(1/fs1):T).';     % time array from 0 to T sec, step 1/fs1
>
> portante = 100*cos(2*pi*fp*t);
>
> plot(portante);
>
> player = audioplayer(portante, fs1);
> play(player);
>
>
> May I thank you in advance,
>
> Best regards
>
> Andrea Mariotti
>
>
>
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]