0
$\begingroup$

In my attempt to generate a standard sine wave out of a sound card, I started using matlab which has a function soundsc for scaling the output

 t = 0:1/48000:10;
 y = sin(1000*2*pi*t);
 soundsc(y,48000,[a b]);

It's ok when my a and b are -1 and 1 respectively. When I try to make them even -0.9 and 0.9 respectively, the standard sine wave of 1Khz gets distorted, why?

Are our sound cards not able to handle standard sounds?

$\endgroup$

1 Answer 1

2
$\begingroup$

Primarily because the documentation is poorly written. If you want to play at half amplitude you need to use

soundsc(y,48000,[-2 2]);

The range argument is the input amplitude range that gets mapped to the maximum available range of the sound card. So if the max of your input exceeds the max in the range argument, you will get clipping.

$\endgroup$
3
  • $\begingroup$ so you mean to say that if i want the waveform [-0.5 0.5] i have to make it [-2 2] assuming sound card limits are [-1 1], but on the other side documentation says [-1 1] are the min and max limits, can you elaborate a bit, thanks $\endgroup$
    – kakeh
    Jul 27, 2015 at 12:00
  • $\begingroup$ mathworks.com/help/matlab/ref/soundsc.html $\endgroup$
    – Hilmar
    Jul 27, 2015 at 21:58
  • $\begingroup$ if you observe the documentation it clearly says it depends on the sound card what are your max and min limits, what ever the limits may be the matlab would scale them to [-1 1] boundaries, and its true i also observe it, what is the point you are trying to make ? $\endgroup$
    – kakeh
    Jul 28, 2015 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.