octave-maintainers
[Top][All Lists]
Advanced

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

Re: Audio playback and classes


From: pantxo diribarne
Subject: Re: Audio playback and classes
Date: Fri, 30 Aug 2013 09:59:04 +0200




2013/7/4 pantxo diribarne <address@hidden>


>
>  - The output sounds chopped, as if the signal was composed of multiple
> frames separated by zeros (or discontinuities at least). I didn't notice
> this issue before the last changes you commited.  I tried with two sampling
> frequencies for the same signal duration :
> fs = 44100;
> t = 0:1/fs:5;
> signal = cos (2 * pi * 440 * t);
> ap = audioplayer ([signal(:) signal(:)], fs);
> playblocking (ap)
> fs = 10000;
> t = 0:1/fs:5;
> signal = cos (2 * pi * 440 * t);
> ap = audioplayer ([signal(:) signal(:)], fs);
> playblocking (ap)
>
> Pantxo
>
>
>
> --
> View this message in context: http://octave.1599824.n4.nabble.com/Audio-playback-and-classes-tp4654378p4655190.html
> Sent from the Octave - Maintainers mailing list archive at Nabble.com.


The same happens to me with those particular calls. However if I
change cos to sin or if I try playing back audio files with music in
them I can hear no glitches. Can someone with better octave knowledge
then mine can comment why can this be?


Hello,

The problem doesn't come from aliasing, but from the signal reaching the max value (1). The following shows the problem :

octave:1> fs = 44100;
octave:2> t = 0:1/fs:1;
octave:3> ycos = cos (2*pi*440*t);
octave:4> ysin = sin (2*pi*440*t);
octave:5> length (ycos (ycos == 1))
ans =  21
octave:6> length (ysin (ysin == 1))
ans = 0
octave:7> ycos(abs (ycos) == 1) *= (1-eps);
octave:8> ap = audioplayer (ycos, fs);
octave:9> play (ap) # Here the sound is clean

There is no problem if I send the data in the form of uint8, even if the signal reaches the max value 255 :

octave:10> ycos = uint8 ((cos (2*pi*440*t) + 1) / 2 * 2^8) ;
octave:11> max (ycos)
ans = 255
octave:12> ap = audioplayer (ycos, fs);
octave:13> play (ap) # Here the sound is also clean

There may be a problem in the conversion from double to int value before passing data to the sound card ?

Pantxo
 

reply via email to

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