Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Audio output using PsychToolboxSoundServer or TeensySoundServer
#1
Hello Josh and other users,

I'm a new user of bpod, and trying to send sound output using bpod.
I have tried "TeensySoundServer", and "PsychToolboxSoundServer" function, but some errors occured.

In case of "TeensySoundServer", I tried following code from bpod wiki.

    SoundDuration = 3; SamplingRate = 44100; % Set parameters

    MyWaveform = rand(2,SoundDuration*SamplingRate); % Create waveform
    TeensySoundServer('init', 'COM7'); % Initialize sound server on port COM3
    TeensySoundServer('load', 1, MyWaveform); % load the sound
    TeensySoundServer('play', 1); % Play the sound
    pause(3);

Teensy were connected to COM7, and connected to bpod serial port.
There are no errors in MATLAB window, but no-sound were played.


In case of "PsychToolboxSoundServer", I sucessed to play sound, but only when the bpod's state is in Emulater mode.

When the bpod connected normally, following error is occured.

       Error: no compatible sound subsystem detected.

I tried two sound card, Xonar U7, or Xonar AE.
but, neither of them were works well.

Could you please give me suggestions on what should I do next?

Thanks a lot for your assistance.
Reply
#2
Hi Hirokawa,

For the Teensy, what kind of microSD card are you using? I'd use SanDisk brand if possible, and make sure it's formatted as FAT16 or FAT32.
Is the Teensy version 3.2, and using firmware from here?

For Xonar AE, in Sonic Studio (see the system tray icon), make sure the card is configured as a 7-channel card. You may have to restart MATLAB after changing the card config.

-Josh
Reply
#3
(06-01-2020, 09:39 PM)Josh Wrote: Hi Hirokawa,

For the Teensy, what kind of microSD card are you using? I'd use SanDisk brand if possible, and make sure it's formatted as FAT16 or FAT32.
Is the Teensy version 3.2, and using firmware from here?

For Xonar AE, in Sonic Studio (see the system tray icon), make sure the card is configured as a 7-channel card. You may have to restart MATLAB after changing the card config.

-Josh

Thank you for your kind reply.

For the Teensy, I'm using Teensy 3.2 with provided firmware.
Also, I'm using Sandisk Ultra microSD card (16GB).

For the Sound card problem, I'm not sure whether the card is configured as a 7-channel card or not.
At this time, I'm usung it with defalt settings. Is it not good?
If it is the problem, I would like to know how to set these configuration.

In addition, I read following thread " https://sanworks.io/forum/showthread.php?tid=545"
I guess this is related to our error, because I'm using PTBversion  3. 0.16.

but if this is a problem, I'm wondering why ' PsychToolboxSoundServer('init')' works only in Emulater mode.

If you have any solution or suggestions, could you please teach me about it ?


Thanks a lot 

Hiro

I tried to use "PsychToolboxAudio.m " plugin, but also I couldn't use it appropriately.


I would like to share the results of following code in my enviroment.
"devices = PsychPortAudio('GetDevices');"

Headphone selected in sound sonic
3 13 'Windows WASAPI' 'SPDIF Out (2- XONAR SOUND CARD)' 0 2 0 0 0.003 0.01 192000
4 13 'Windows WASAPI' '繝倥ャ繝峨�繝ウ (2- XONAR SOUND CARD)' 0 2 0 0 0.003 0.01 192000

Speaker selected in Sound Sonic
3 13 'Windows WASAPI' 'SPDIF Out (2- XONAR SOUND CARD)' 0 2 0 0 0.003 0.01 192000
4 13 'Windows WASAPI' '繧ケ繝斐�繧ォ繝シ (2- XONAR SOUND CARD)' 0 2 0 0 0.003 0.01 48000

Actually, I think my sound card Xonar AE is not configurated appropriately.
And, did not passed line 72 of PsychToolboxAudio.m
"if devices(CandidateDevices(i)).NrOutputChannels > 3"


If you have any solution,  I would like to get some information.

Also, I'm considering to change the enviroments MATLAB to Python, or change sondcard to "Fenix HTomega", if it will solve my situation.
Reply
#4
Hi Hiro,

It totally escaped me the first time you wrote - the TeensySoundServer plugin is deprecated, and not compatible with the latest software.
If you were to use it, the function call to load is TeensySoundServer('LoadWaveform', N, W) rather than ('Load', N, W).
Beyond that, TeensySoundServer refers to a path that doesn't exist in the latest software. I patched it on the 'develop' branch of the repository, but I have a better suggestion.

Instead of TeensySoundServer, use the TeensyAudioPlayer class in the Bpod_Gen2 repository, here.
Usage is:
Code:
T = TeensyAudioPlayer('COM3'); % Where COM3 is the correct port for Teensy

T.load(N, Waveform); % Where N is the index of the sound

T.play(N); % Plays sound N.

clear T; % Clears the object, closes its USB serial port


For Sonic Studio configuration, referring to the screenshot here, make sure the 'Speakers' icon is selected, and in 'Playback Configuration' where it shows 'Stereo', select 7-channel.

Sound in Emulator mode is routed through MATLAB's sound() command - so it uses very slow drivers, and your PC's default configuration.

Please be advised that we now recommend HTOmega Fenix for all Windows users. Its ultrasonic response is much flatter than Xonar AE above 60kHz, it works with low latency  (~10ms) with PsychToolbox via WASAPI drivers (unfortunately they dropped faster ASIO drivers), and its output channels can directly drive the state machine's BNC input channels for sync. Fenix also comes with a configuration utility similar to Sonic Studio, where you have to select 7-channel mode in order for PsychToolboxSoundServer to recognize the card.

I hope this helps!

-Josh
Reply
#5
(06-06-2020, 04:50 PM)Josh Wrote: Hi Hiro,

It totally escaped me the first time you wrote - the TeensySoundServer plugin is deprecated, and not compatible with the latest software.
If you were to use it, the function call to load is TeensySoundServer('LoadWaveform', N, W) rather than ('Load', N, W).
Beyond that, TeensySoundServer refers to a path that doesn't exist in the latest software. I patched it on the 'develop' branch of the repository, but I have a better suggestion.

Instead of TeensySoundServer, use the TeensyAudioPlayer class in the Bpod_Gen2 repository, here.
Usage is:
Code:
T = TeensyAudioPlayer('COM3'); % Where COM3 is the correct port for Teensy

T.load(N, Waveform); % Where N is the index of the sound

T.play(N); % Plays sound N.

clear T; % Clears the object, closes its USB serial port


For Sonic Studio configuration, referring to the screenshot here, make sure the 'Speakers' icon is selected, and in 'Playback Configuration' where it shows 'Stereo', select 7-channel.

Sound in Emulator mode is routed through MATLAB's sound() command - so it uses very slow drivers, and your PC's default configuration.

Please be advised that we now recommend HTOmega Fenix for all Windows users. Its ultrasonic response is much flatter than Xonar AE above 60kHz, it works with low latency  (~10ms) with PsychToolbox via WASAPI drivers (unfortunately they dropped faster ASIO drivers), and its output channels can directly drive the state machine's BNC input channels for sync. Fenix also comes with a configuration utility similar to Sonic Studio, where you have to select 7-channel mode in order for PsychToolboxSoundServer to recognize the card.

I hope this helps!

-Josh

Hi Josh,

Thank you so much for your kind assistance !
I could use "PsychToolboxSoundServer" function in my environment, after Sonic Studio configuration.
Now, I'm starting to build behavioral tasks using bpod, and enjoying them.
I would like to get HTOmega Fenix, and try it soon.

Thank you, again!

Hiro
Reply


Forum Jump: