function raspi_pitchshiftdeployment() %该函数用于将音频处理应用程序部署到% Raspberry Pi中。兴趣的具体应用是音高转换。%此函数从连接到树莓% Pi的设备中获取音频输入,音高将音频输入转换为所需的音高,然后将此输出发送到连接到树莓Pi的播放设备。在%树莓派硬件上创建用于音频处理的捕获和播放系统对象。r = raspi ();captureObj = audicapture (r,'plughw:2,0','SampleRate', 48000, 'SamplesPerFrame', 4800);playbackObj = audioplayer(r,'plughw:2,0', 'SampleRate', 48000);节距转换操作的%设置节距= -5;半音调重叠的音高偏移= 0.2;延迟线重叠率Fs = 8192; % Sampling Frequency pitchShifter = audiopluginexample.PitchShifter('PitchShift',8,'Overlap',0.3); setSampleRate(pitchShifter,Fs); for k = 1:3000 % capture audio input from the input device input = capture(captureObj); % pitch shift the audio input. % input is of type int16 and needs to be converted to type double % before processing the data. This is because the function shiftPitch % expects all its inputs to be of the same data type which in this case % is type double pitchShifted = zeros(size(double(input)),'like',double(input)); %#ok pitchShifter.PitchShift = pitch; pitchShifter.Overlap = overlap; [pitchShifted] = pitchShifter(double(input)); % playback audio output using the output device % output data needs to be of type int16 and thus pitchShifted % which is a double is cast to be of type int16 before being sent to % the device play(playbackObj,int16(pitchShifted)); end end