How do I get sound data from a speaker?

I googled it, but all I could find was how to send data to a speaker. I want to Analyse the sound the speaker is outputting. I thought I could perhaps use the same method that I used for my microphone, which is:
d = daq.getDevices;
dev = d(2);
s = daq.createSession('directsound');
ch = addAudioInputChannel(s, dev.ID, 1);
s.IsContinuous = true;
lh = addlistener(s,'DataAvailable', @(src, event) analyze_bandpower(event.Data));
startBackground(s);
But, when I changed the device to a speaker it didn't work. Is there a way to do this with a speaker instead of a microphone?
Edit: I think I need to change how I am saying what I need. Basically I want to be able to analyze system sounds. Like I have some music from pandora playing on my desktop, and I want to analyze the frequencies in it. Would that be any different?

댓글 수: 4

John Hackett
John Hackett 2018년 3월 8일
Is this place so dead, that my question only had 6 views in the last 2 days, or did I miss a tag or something?
Walter Roberson
Walter Roberson 2018년 3월 8일
As of the time of my writing, there have been 474 new Questions since you posted your Question, over 200 per day. The active volunteers paddle as fast as we can, but we are getting swamped.
John Hackett
John Hackett 2018년 3월 9일
Wow, that is a lot. However, is there no way to at least let someone know, 'Hey we are busy right now, we'll get back to you in x time'?
Walter Roberson
Walter Roberson 2018년 3월 9일
There is no roster of volunteers, no deliberate division of effort, no queuing of questions to particular people. Each of the volunteers visits whenever they feel like it, wanders off whenever they want, and responds to whatever strikes their interest.
Some of the volunteers only answer questions they already know the answer to (perhaps because it is somewhat fast and doesn't require much thinking); some of them prefer questions that are within areas they have studied but do not already know the answer to (perhaps in order to expand their expertise in their chosen areas); some volunteers enjoy questions that are further out from their existing knowledge (perhaps in order to expand their areas of knowledge, that moving out of comfort zones can also present the greatest learning opportunities.)
The audio driver specialist volunteers tend to wander by about every 4 to 6 months. You typically won't see one of them responding unless you start working with at least 8 channels -- or start needing very low latency.
Myself, I have not done audio work for about 35 years, back on a PDP-11/23 device (I think it was.) There were no audio drivers back then; we programmed everything in assembly language.

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2018년 3월 8일

0 개 추천

"Is there a way to do this with a speaker instead of a microphone?"
No.
If you want to analyze the sound a speaker is putting out then you need to do one of the following:
  1. add one or more microphones listening to the speakers; Or
  2. add an analog to digital convertor on a tap of the inputs going to the speaker and extensively calibrate how input signals are converted to sound by the speaker so that the input signal can serve as a proxy for the speaker output; Or
  3. loop-back the signal being output in the direction of the speakers and extensively calibrate how the signals being emitted at that point are converted to sound by the speaker so that the signal can serve as a proxy for the speaker output. The differences between this and the previous option is: (A) that the system output being measured in this case might be pre-amp, pre-equalizer and so on whereas the direct measurement of the signal to the speaker would be after all manipulations including amplifier; and (B) there is a possibility that you might be able to loop back the digital version of the signal before it is converted to output
As I scan around the 'net it appears that DirectSound does not have the capability of doing loopback, but that some other audio drivers do. One of the ones suggested appears to be https://www.vb-audio.com/Cable/

댓글 수: 4

John Hackett
John Hackett 2018년 3월 9일
Is it really such a difficult thing to do? I would think all you would need to do is to tell the audio driver, 'Hey, send this sound data to me too' or even 'Send this data to me instead of the speaker, I need to do something to it before I send it back on it's way'?
Walter Roberson
Walter Roberson 2018년 3월 9일
You are configuring to use Direct Sound as the driver. The material I find for Direct Sound suggests that it is not able to do loopback.
But your question was about analyzing the sound your speaker is putting out. That is going to depend upon all of the steps between the analog signal source and the speaker cones (if they even have cones.) Cable quality. Impedance mismatches. Interference. Ground loops. Pre-amp. Mixer. FX devices. Equalizer. Amplifier. Speaker splitting the signal into bands and sending the bands to the different cones and woofers. Response characteristics of the speaker.
Look at https://www.youtube.com/watch?v=sKC3ioWXG38 -- there is no way you should expect the paper cup speaker to have the same response as the professional speaker, and the actual response is not something you can know just by knowing what the output signal is from the host.
John Hackett
John Hackett 2018년 3월 9일
I've added an edit to my question, please let me know if that changes anything.
Walter Roberson
Walter Roberson 2018년 3월 9일
I think my first attempt at this point would be to try the Virtual Cable driver I linked to above and see if a device shows up for the data acquisition toolbox or (more likely I guess) the Audio System Toolbox.

댓글을 달려면 로그인하십시오.

Anan Yaghmour
Anan Yaghmour 2020년 7월 4일

0 개 추천

hello,
Have you tried to activate stereo mix mode , in order to enable direct recording from speakers?

카테고리

도움말 센터File Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

질문:

2018년 3월 6일

답변:

2020년 7월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by