The example for outputing audio through only one channle doesn't work for me.. (audioDeviceWriter & audioOscillator)
Mostra commenti meno recenti
I can't get this example to work at all - it's supposed to play a sine wave in one channle, and a static through the other, but I still get sound from both channles.
I've tried substituting zeros for randn to totally mute the other channel, but it had no effect either.
dev_writer = audioDeviceWriter;
sineGenerator = audioOscillator;
sineGenerator.Frequency = note2Freq(79);
count = 0;
sine = sineGenerator();
static = zeros(length(sine),1);
while count < 1000
dev_writer([sine,static]);
count = count + 1;
end
5 Commenti
jibrahim
il 13 Set 2022
not sure about your set-up, but this seems to work (silence in one ear, sine in the other). If you want to hear the actual sine wave progressing, you will need to move the call to inside the for loop though:
dev_writer = audioDeviceWriter;
sineGenerator = audioOscillator;
sineGenerator.Frequency = note2Freq(79);
count = 0;
static = zeros(length(sine),1);
while count < 1000
sine = sineGenerator();
dev_writer([sine,static]);
count = count + 1;
end
Jonathan Sahar
il 14 Set 2022
jibrahim
il 14 Set 2022
Hi Jonathan,
audioOscillator does not return the same sine wave each time you call it. When you call it, it will give you a frame of the sine wave (controlled by value of SamplesPerFrame). When you call it again, you get the next sine wave frame in time. If you stitch/plot consecutive outputs of the oscillator, you get the repeating sine wave. One output of the oscillator might just be a small part of the sine wave period, or could include multiple periods: that all depends on SamplesPerFrame and SampleRate.
Jonathan Sahar
il 28 Set 2022
Walter Roberson
il 28 Set 2022
If the samples per frame is not an integer multiple of samples per cycle then the calls to the generator will not return the same result.
For example if you ask for 10000 samples per frame and a sample frequency of 22100 Hz then one frame would be 2.21 cycles, and the second call to the generator would start 0.21 cycles in, not at the beginning of a cycle
Risposte (0)
Categorie
Scopri di più su Audio I/O and Waveform Generation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!