在特定耳塞(频道)上播放歌曲
playing song on a specific earplug (channel)
我有一个设备,就像 3 个耳机合二为一(所以 6 个耳塞)。我的目标是在每个耳塞上播放一首不同的歌曲(6 首歌曲)。所以我开始在耳塞上播放一首歌。对我来说,一个频道意味着一个耳塞(但也许我错了)。我正在使用 Psychtoolbox:
function BasicSoundOutputDemo( wavfilename)
AssertOpenGL;
% Read WAV file from filesystem:
[y, freq] = psychwavread(wavfilename);
aux = y' ;
wavedata = aux(1,:);
InitializePsychSound;
devices = PsychPortAudio('GetDevices' );
pahandle = PsychPortAudio('Open', [], [], 0, freq, 1);// nr channels = 1
PsychPortAudio('FillBuffer', pahandle, wavedata);
t1 = PsychPortAudio('Start', pahandle, 1, 0);
KbReleaseWait;
while ~KbCheck
% Wait a seconds...
WaitSecs(1);
end
PsychPortAudio('Stop', pahandle);
PsychPortAudio('Close', pahandle);
fprintf('Demo finished, bye!\n');
但是没有用。它不是只在一个耳塞上播放声音,而是在 2 个耳塞上播放。
我收到此警告
PTB-INFO: Using specially modified PortAudio engine, based on offical
version: PortAudio V19-devel WITH-DIM
Will use ASIO enhanced Portaudio driver DLL. See
Psychtoolbox/PsychSound/PortAudioLICENSE.txt for the exact terms of
use for this dll.
Disclaimer: "ASIO is a trademark and software of Steinberg Media
Technologies GmbH."
PTB-Warning: Although using the ASIO enabled Psychtoolbox sound
driver,
PTB-Warning: could not find any ASIO capable soundcard in your system.
PTB-Warning: If you think you should have an ASIO card, please check
your
PTB-Warning: system for properly installed and configured drivers and
retry.
PTB-Warning: Read "help InitializePsychSound" for more info about ASIO
et al.
PTB-INFO: New audio device with handle 0 opened as PortAudio stream:
PTB-INFO: For 1 channels Playback: Audio subsystem is MME, Audio
device name is Microsoft Sound Mapper - Output
PTB-INFO: Real samplerate 44100.000000 Hz. Input latency 0.000000
msecs, Output latency 464.399093 msecs.
然后我决定尝试另一个方法。让我们用其他 2 个耳塞播放这首歌
我使用 PsychPortAudio('GetDevices') 找到了这对耳塞的 ID。奇怪的是,我发现了 4 个设备,而不是 3 个设备和 2 个通道。
而且我使用 PsychPortAudio('Open' 用于 id 7、9、18 和 20,但每次在同一对耳塞上播放歌曲时,我尝试只用一个耳塞播放时的同一对。
这是4台设备的照片
function BasicSoundOutputDemo( wavfilename)
AssertOpenGL;
% Read WAV file from filesystem:
[y, freq] = psychwavread(wavfilename);
wavedata = y' ;
nrchannels = size(wavedata,1); % Number of rows == number of channels.
InitializePsychSound;
devices = PsychPortAudio('GetDevices' );
pahandle = PsychPortAudio('Open', 18, [], 0, freq, nrchannels);
PsychPortAudio('FillBuffer', pahandle, wavedata);
t1 = PsychPortAudio('Start', pahandle, 1, 0);
KbReleaseWait;
while ~KbCheck
% Wait a seconds...
WaitSecs(1);
end
PsychPortAudio('Stop', pahandle);
PsychPortAudio('Close', pahandle);
fprintf('Demo finished, bye!\n');
现在唯一不同的地方是这个
PTB-INFO: For 2 channels Playback: Audio subsystem is Windows
DirectSound, Audio device name is Speakers (USB Multi-Channel Audio
Device)
抱歉这么久 post 但我想为您提供所有信息。
你能看出我错了吗?如何在特定的耳塞上播放一首歌曲。我想如果我知道,那么我只需复制代码并放另一首歌曲,这样我就会在每个耳塞上播放一首歌曲
1) 您可能不希望每次播放声音时都 运行 AssertOpenGL
。
2) 您的代码看起来是正确的,但有趣的是在我的 Apple 笔记本电脑和内置声音上,发送单通道信号也会从两个耳机通道播放。
3) 您使用的是什么音频设备?从您的设备列表来看,您列出的 4 个可能是相同设备的不同接口(2 个输出(一个数字,一个模拟)X 两个 API(一个 MME,一个 DirectSound)。您的设备中是否还有其他条目名单?
我的问题的部分答案。我找到了如何在耳塞中播放一首歌曲,在另一个耳塞中播放另一首歌曲。 psychwavread 给了我一个 2 行数组。所以我把一首歌的第一行和另一首歌的第一行放在一个数组中。所以现在我有一个 2 行数组,类似于我播放一首歌曲时的数组,但现在我播放了 2 首歌曲
[y, freq] = psychwavread(wavfilename1);
[y1, freq1] = psychwavread(wavfilename2);
aux = y';
aux1 = y1';
wavedata = [aux1(1,:) ; aux(1,:)];
所以我设法在 4 个频道上播放我确信我可以在 6 和 8 上播放。我安装了 ASIO4ALL 并在打开时选择 ASIO4ALL 设备 ID。当 ASIO4all 打开时,我可以选择我的 6 通道设备,然后我只需在打开功能中选择播放声音的通道
我有一个设备,就像 3 个耳机合二为一(所以 6 个耳塞)。我的目标是在每个耳塞上播放一首不同的歌曲(6 首歌曲)。所以我开始在耳塞上播放一首歌。对我来说,一个频道意味着一个耳塞(但也许我错了)。我正在使用 Psychtoolbox:
function BasicSoundOutputDemo( wavfilename)
AssertOpenGL;
% Read WAV file from filesystem:
[y, freq] = psychwavread(wavfilename);
aux = y' ;
wavedata = aux(1,:);
InitializePsychSound;
devices = PsychPortAudio('GetDevices' );
pahandle = PsychPortAudio('Open', [], [], 0, freq, 1);// nr channels = 1
PsychPortAudio('FillBuffer', pahandle, wavedata);
t1 = PsychPortAudio('Start', pahandle, 1, 0);
KbReleaseWait;
while ~KbCheck
% Wait a seconds...
WaitSecs(1);
end
PsychPortAudio('Stop', pahandle);
PsychPortAudio('Close', pahandle);
fprintf('Demo finished, bye!\n');
但是没有用。它不是只在一个耳塞上播放声音,而是在 2 个耳塞上播放。
我收到此警告
PTB-INFO: Using specially modified PortAudio engine, based on offical version: PortAudio V19-devel WITH-DIM
Will use ASIO enhanced Portaudio driver DLL. See Psychtoolbox/PsychSound/PortAudioLICENSE.txt for the exact terms of use for this dll.
Disclaimer: "ASIO is a trademark and software of Steinberg Media Technologies GmbH."
PTB-Warning: Although using the ASIO enabled Psychtoolbox sound driver,
PTB-Warning: could not find any ASIO capable soundcard in your system.
PTB-Warning: If you think you should have an ASIO card, please check your
PTB-Warning: system for properly installed and configured drivers and retry.
PTB-Warning: Read "help InitializePsychSound" for more info about ASIO et al.
PTB-INFO: New audio device with handle 0 opened as PortAudio stream:
PTB-INFO: For 1 channels Playback: Audio subsystem is MME, Audio device name is Microsoft Sound Mapper - Output
PTB-INFO: Real samplerate 44100.000000 Hz. Input latency 0.000000 msecs, Output latency 464.399093 msecs.
然后我决定尝试另一个方法。让我们用其他 2 个耳塞播放这首歌
我使用 PsychPortAudio('GetDevices') 找到了这对耳塞的 ID。奇怪的是,我发现了 4 个设备,而不是 3 个设备和 2 个通道。
而且我使用 PsychPortAudio('Open' 用于 id 7、9、18 和 20,但每次在同一对耳塞上播放歌曲时,我尝试只用一个耳塞播放时的同一对。
这是4台设备的照片
function BasicSoundOutputDemo( wavfilename)
AssertOpenGL;
% Read WAV file from filesystem:
[y, freq] = psychwavread(wavfilename);
wavedata = y' ;
nrchannels = size(wavedata,1); % Number of rows == number of channels.
InitializePsychSound;
devices = PsychPortAudio('GetDevices' );
pahandle = PsychPortAudio('Open', 18, [], 0, freq, nrchannels);
PsychPortAudio('FillBuffer', pahandle, wavedata);
t1 = PsychPortAudio('Start', pahandle, 1, 0);
KbReleaseWait;
while ~KbCheck
% Wait a seconds...
WaitSecs(1);
end
PsychPortAudio('Stop', pahandle);
PsychPortAudio('Close', pahandle);
fprintf('Demo finished, bye!\n');
现在唯一不同的地方是这个
PTB-INFO: For 2 channels Playback: Audio subsystem is Windows DirectSound, Audio device name is Speakers (USB Multi-Channel Audio Device)
抱歉这么久 post 但我想为您提供所有信息。
你能看出我错了吗?如何在特定的耳塞上播放一首歌曲。我想如果我知道,那么我只需复制代码并放另一首歌曲,这样我就会在每个耳塞上播放一首歌曲
1) 您可能不希望每次播放声音时都 运行 AssertOpenGL
。
2) 您的代码看起来是正确的,但有趣的是在我的 Apple 笔记本电脑和内置声音上,发送单通道信号也会从两个耳机通道播放。
3) 您使用的是什么音频设备?从您的设备列表来看,您列出的 4 个可能是相同设备的不同接口(2 个输出(一个数字,一个模拟)X 两个 API(一个 MME,一个 DirectSound)。您的设备中是否还有其他条目名单?
我的问题的部分答案。我找到了如何在耳塞中播放一首歌曲,在另一个耳塞中播放另一首歌曲。 psychwavread 给了我一个 2 行数组。所以我把一首歌的第一行和另一首歌的第一行放在一个数组中。所以现在我有一个 2 行数组,类似于我播放一首歌曲时的数组,但现在我播放了 2 首歌曲
[y, freq] = psychwavread(wavfilename1);
[y1, freq1] = psychwavread(wavfilename2);
aux = y';
aux1 = y1';
wavedata = [aux1(1,:) ; aux(1,:)];
所以我设法在 4 个频道上播放我确信我可以在 6 和 8 上播放。我安装了 ASIO4ALL 并在打开时选择 ASIO4ALL 设备 ID。当 ASIO4all 打开时,我可以选择我的 6 通道设备,然后我只需在打开功能中选择播放声音的通道