Table of Contents

Adjust volume

By default, the Sound Card plays stored sounds at the amplitude of the stored waveform and pure tones at maximum amplitude. The volume can be adjusted by setting an attenuation for the output channels. Upload a sound to sound index 2 with the Sound Card app or in Bonsai, which we will use for these examples.

Note

Pure tone playback from the internal sine wave generator is currently limited (as of firmware v3.0) to the Right Channel. Connect the amplifier and speaker to this channel if you plan to play pure tones.

This article covers how to set the attenuation when starting a sound and how to change it while a sound is playing in Bonsai.

The complete workflow is shown below. Copy and paste it into Bonsai to get started immediately, or build each section by following the step-by-step instructions in the following sections.

Adjust volume

Attenuate and play sound

AttenuationStart starts playback of a sound index or pure tone and sets the attenuation of the left and right channels at the same time, in 0.1 dB steps. Each command replaces the previous value rather than adding to it. The attenuation also stays in effect. Any sound you play afterward with Start plays at that level until you change it.

Attenuate and play sound

  • Insert a KeyDown operator and set the Filter property to A.
  • Insert a CreateMessage operator and configure the following properties:
    • Payload - Select AttenuationStartPayload.
    • AttenuationStart - Click on the dialog button in the property grid to open the member collection editor. Add three members:
      • The sound index or pure tone frequency to be played (e.g. 2).
      • The attenuation of the left channel (e.g. 200 = -20 dB).
      • The attenuation of the right channel (e.g. 200 = -20 dB).
  • Insert a MulticastSubject operator named SoundCard Commands.

Run the workflow and press the A key to play the sound at reduced volume.

Note

The maximum volume for playback of stored waveforms depends on the recorded amplitude. Upload waveforms at full 24-bit depth to maximize the volume.

Note

A pure tone played with AttenuationStart keeps playing until you send a Stop command. AttenuationStart does not have an event of its own. The device reports the command as a Start event.

Attenuate channels

Use AttenuationBoth to set the attenuation of both channels before or during sound playback.

Attenuate channels

  • Insert a KeyDown operator and set the Filter property to S.
  • Insert a CreateMessage operator and configure the following properties:
    • Payload - Select AttenuationBothPayload.
    • AttenuationBoth - Click on the dialog button in the property grid to open the member collection editor. Add two members:
      • The left channel attenuation (e.g. 100 = -10 dB).
      • The right channel attenuation (e.g. 100 = -10 dB).
  • Insert a MulticastSubject operator named SoundCard Commands.

Run the workflow and press A to play the sound with AttenuationStart and S to change the volume with AttenuationBoth while the sound is playing. With the values above, the sound becomes louder, going from more attenuation to less.

Note

Use AttenuationLeft or AttenuationRight to set the attenuation of each channel independently.

Note

The AttenuationLeft and AttenuationRight fields of the AdcControlState event report the attenuation last set on each channel by a register write. Sounds started from a digital input apply their own attenuation without updating these fields. Refer to the Acquire analog data article to enable and visualize the event.



Documentation for release v3.0.0