winsound not working in MATLAB 64 bit version for reading/writing from/to the sound card

10 views (last 30 days)
Dear Mr/Mrs,
What is the alternative to use 'winsound' for MATLAB 64bit version? This used to work in previous MATLAB versions: daqinfo = daqhwinfo('winsound'); And I'm getting the following: Error using daqhwinfo (line 42) To learn about using data acquisition devices on the win64 platform, see the documentation on the session-based interface.
So I read a little bit, and apparently only 'ni' devices are supported for 64bit. So I tried: AI = analoginput('winsound'); And I'm getting almos the same: Error using analoginput (line 46) To learn about using data acquisition devices on the win64 platform, see the documentation on the session-based interface.
Probably I should try something like: s = daq.createSession('ni'); s.addAnalogInputChannel('???????')
What should I put in ???????? to read the soundcard?
Pablo
  4 Comments
Pablo
Pablo on 14 Oct 2013
[SOLVED] I was able to get data out of the sound card using the following code. In my application, the record_off function triggers the record function again, in order to simulate continuous acquisition.
function reading_soundcard()
global loops;
loops = 2;
fs = 44100; % Sampling frequency in Hz
nbits = 16; % number of bits
acq_ch = 1; % acquisition channel
secs2rec= 1;
% creating object for recording:
lineinput = audiorecorder(fs, nbits, acq_ch);
lineinput.StopFcn = {@record_off,lineinput};
% The function recording_off will be called when the
% recording is done.
record(lineinput, secs2rec); % start the recording
end
function record_off(obj,event,lineinput)
d = getaudiodata(lineinput, 'double');
disp(['number of points recorded:',num2str(length(d))]); %
end

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 30 Oct 2012
Edited: Star Strider on 30 Oct 2012
I suggest audiorecorder. I do not know what your application is, but this and its related functions may work for you. There are links to the others at the end of the documentation page for audiorecorder.
  1 Comment
Pablo
Pablo on 14 Oct 2013
Better later than never: Thanks for the suggestion. I was able to solve the issue by using audiorecorder. I will comment on my solution later on.

Sign in to comment.

More Answers (3)

Mario
Mario on 26 Jun 2013
Unfortunately there is no alternative, if you want to use your standard sound card (this means if you want to use any internal/external microphone that passes through your sound card) you must use the 32 bits version of MATLAB and Data Acquisition Toolbox. Otherwise you need a NIDaq device (National Instruments Data Acquisition), they cheapest ones are around 100USD. Another compatible cheaper DAQ is the Digilent Analog Discovery.

Sean de Wolski
Sean de Wolski on 26 Jun 2013

shanxi Univercity
shanxi Univercity on 13 Oct 2013
I also have this problem.

Community Treasure Hunt

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

Start Hunting!