ITKeyword,专注技术干货聚合推荐

注册 | 登录

matlab - DSP Audio Function Block to Audio Output

分享于

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1073

【阿里云】双十一活动,全年抄底价,限时3天!(老用户也有),
入口地址https://www.aliyun.com/1111/home

推荐:Define the input/output port name for the Inlined C++ S-function block in Matlab Simulink

DO IT by the Mask option of the context menu of the block by right-click mouse button. and input the text like   disp('Metropolis Hastings/n(MH) sampl

up vote 0 down vote favorite I have a simulink block which takes a function from matlab and takes the output of that as an input to the "To Audio Device" diagram. The error I get with this is Port Audio: Invalid number of channels..So I added the variable H to record audio with the DSP.AudioRecorder, but I can't set that as an output H = fcn() .. So main question is what's the simplest way to do this because I'm pretty lost right now. Thanks! The following code I have is:

function y = fcn()

%#codegen

Fs = 125;

%# Samples per second

toneFreq = 50;

%# Tone frequency, in Hertz

nSeconds = 2;

%# Duration of the sound

y = sin(linspace(0, nSeconds*toneFreq*2*pi, round(nSeconds*Fs)));

coder.extrinsic('sound');

coder.extrinsic('audiowrite');

H = dsp.AudioRecorder('DeviceName','Default', 'SampleRate', 48000, 'BufferSizeSource',

'Property', 'BufferSize', 512, 'NumChannels', 2);

step(H);

sound(y, Fs);

%# Play sound at sampling rate Fs

audiowrite(y, Fs, 8, 'tone_50Hz.wav');

%# Save as an 8-bit, 1 kHz signal

matlab signal-processing simulink
  |
  this question asked Sep 18 '13 at 14:55 user1819301 68 3 13



 |  1 Answers

up vote 0 down vote "To Audio Device" block considers each column as a channel. You should transpose your data y before returning as output from fcn. Currently you are getting the error because you have a row vector as y and each sample in this row vector is being considered a separate channel.
  |
  this answer answered Sep 19 '13 at 18:46 Navan 3,931 1 17 19



 | 

up vote 0 down vote favorite I have a simulink block which takes a function from matlab and takes the output of that as an input to the "To Audio Device" diagram. The err

相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。