Welcome Guest, you are in: Login

EventIDE Wiki

RSSRSS

Navigation




Search the wiki


PoweredBy

Page History: Wave Player Element

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: 2012/05/21 19:53


Element Icon Wave Player Element
Info
Category: Auditory stimuli AddIn: Base Elements
Creator: OkazoLab Team Scope: Parent Event
Owns Snippets: On Triggered Usage: Design-time,Runtime,Snippets
Wave Player element is capable of playing audio clips in the Waveform Audio File Format (WAV) with high temporal accuracy.


Description

Wave Player is a default element in EventIDE for delivering audio stimuli stored in the Wave format. The element is recommended for modern sound cards on Vista and Windows 7 OS system, when high temporal accuracy of audio playback is required. For Windows XP and old sound cards the Direct Sound element may produce more accurate results.

The Wave Player element allows to choose one of four audio playback API: DirectSound, WaveOut (also known asWaveform Audio API), ASIO and WASAPI.

In the most cases, WSAPI in the exclusive mode delivers the best temporal accuracy and fidelity of audio playback. (for example, the mid-range Creative SB X-Fi Titanium Professional card, used in Windows 7, allows to start a playback just in 2ms after onset of the parent event)

The Wave Player element allows selection of the output sound device when multiple sound cards installed on a computer.

For some professional sound cards another low-level sound API,Audio Stream Input/Output ASIO, can be recommended. Using ASIO API and compatible sound hardware and drivers (the last two are essential) may also help to achieve perfect temporal precision and fidelity.

Wave Player element supports the majority of resolutions and encodings used in the Wave format. The element automatically converts input wave clips into uncompressed PCM data streams before a playback. Since the conversion takes some time, using the uncompressed PCM wave clips is recommended for faster processing of audio stimuli.

Snapshots

Wave Player element is used in  the 'media player' demo  made with EventIDE

Wave Player element is used in
the 'media player' demo
made with EventIDE


Element Demo

The 'WaveAudioPlayer' demo for the Wave Player element can be found in 'Demos\Elements\Audio_Stimuli\' subfolder under the main program folder.

When to use the Wave Player element

EventIDE provides several elements for delivering auditory stimuli. The audio elements have similar functionality and a choice depends on design demands and the used sound hardware. A guidance on selecting an audio element is available in Auditory stimuli article.

In short, the Wave Player element is the simplest and most recommended audio element, especially if Windows Vista/7 system and modern sound card is used.

Stimulus Set

The element can be easily adapted to make up an audio stimulus set that contains multiple audio clips. Then one of these clips can be selected to be played in the given trial. To make a stimulus set, load selected audio clips from Material Library directly into the element (e.g. by drag and drop). Then use the Item Index property to select an audio clip for playback. It's recommended to change the Item Index property before the onset of the parent event because preparing the clip for playback takes some time.

Practical Use

  1. Add a new Wave Player element into the selected event (where an audio has to be played).
  2. Select the element in the Element Panel, then its properties will appear in the Property panel at the right.
  3. Load selected audio clips from the Material Library to the item list of the element and select the current clip via Item Index property.
  4. Browse to the Hardware Settings group in the element properties and select Playback API and Sound Device in the corresponding properties.
  5. Select a playback mode for the element in the Playback Setting group. The most common mode for presentation of auditory stimulus is "Single playback on onset of the parent event"
  6. Test, if an audio is played by clicking over the Test Playback property.
  7. Make sure that duration of the parent event is greater or equal to duration of the selected audio clip- an audio playback is always aborted on offset of the parent event.

Playback modes

At runtime the element can work in 3 different playback modes, which define how playback process starts and stops. The mode has to be selected at design-time and cannot be changed. However, it's possible to use multiple elements working in different modes in parallel. The available modes are:

Single playback on event onset

In this mode the element starts to play an audio synchronously with activation of the parent event. The audio is played once. When the playback stops you can initiate a new one manually if the parent event is still active.

Looped playback on event onset

In this mode the element starts to play an audio synchronously with activation of the parent event and automatically restarts the playback as soon as the end of the audio clip is reached. This playback loop lasts until deactivation of the parent event.

Manual mode

In this mode the playback is controlled solely by element's IsPlaying property, which can be changed in snippets. If IsPlaying is set to true before onset of the parent event, the playback behaviour will be similar to 'Single playback on event onset' mode. If the parent event is active, the playback starts/stops on a change of the IsPlaying property. The Is Playing property automatically turns to false when the playback ends.

Triggering at the end of the playback

In some experimental scenarios it can be reasonable to end the parent event immediately after finishing a playback of the current audio. Since the same Wave Player element can switch between multiple audio clips of different durations, the duration of the parent event can not be set to a fixed value. The Wave Player elements offers an easy solution - the element monitors a playback process and gets triggered at the end of each audio clip. Triggering is followed by a call of the OnTriggered snippet, which can contain user programmed actions. In addition, the element has a boolean status property, called Is Triggered, which can be used directly to control the event flow in EventIDE.

Notes

  1. The Wave Player element is optimized to deliver the best timing accuracy and fidelity of audio playback. However, it's always recommended to measure empirically the timing of the actual playback when high accuracy is required. The measurements can be done with oscilloscope connected to the output of sound card and photo-diode on a monitor. Probing different settings of the element in such testing can help to achieve the optimal results.
  2. Slightly better onset of the audio playback can be achieved if the element is placed at the top of the elements list in the parent event. Elements in the list get activated one by one on the onset of the parent event, so the top position in the list will minimize the onset delay.

Properties

Generic properties

NameDescriptionAttributesValue TypeProxy Reflex
Hardware Settings
Playback APIDefines API for the audio playback. WASAPI is not supported in Windows XP but is recommended by default for Windows Vista/7. ASIO API requires appropriate drivers.Enum List
Sound Device Defines a sound device for the audio playback, when multiple devices are available in the system. Different playback API return their own device list for selection.Enum List
Share ModeDefines whether the selected sound device will be used in the shared or exclusive mode. This setting is relevant only when WASAPI is chosen. The exclusive mode greatly improves timing accuracy of audio playback and is recommended for stimulus presentation. As a drawback, only one sound can be played per time in the exclusive mode.Enum List
ASIO COntrol PanelOpens a control panel with ASIO driver settings Design-time action
Buffer LatencyDefines the size of the internal audio buffer (in ms), where wave data is loaded just before playback. Small buffers may cause CPU overhead, but guarantee faster playback adjustments, e.g. for the volume. Large buffers usually are better for smooth playback. The typical range for the property value is between 25- 500 ms. The property value is ignored when ASIO API is used. System.Int32
Test PlaybackInitiates a single playback of the currently selected clip using the chosen hardware settings of the element Design-time action Returns an error message, if the playback fails.
Playback Settings
Playback ModeDefines the playback mode for audio clips played by the element. In the default mode (Single Playback), a clip is played once on the onset of the parent event. In the Manual mode the playback process is controlled in the snippets by changing the Is Playing property.Enum List
Playback End Monitoring Defines whether the element monitors its own playback process at runtime. Enabling this property allows more accurate detection of the end of the playback. As a drawback, monitoring may marginally impair the timing accuracy of the playback start and, therefore, is not recommended for precise stimulus presentation. System.Boolean
Playback Controls
Current Clip InfoReturns a structure containing an info about the currently selected audio clip. Click to expand all fields.FORMATTER ERROR (Snippet Not Found) BaseElements.stWaveBufferInfo
VolumeVolume, from ground (0) to full (100), of the playback of a wave audio DoubleAdjusts the volume of played audio.
BalanceStereophonic balance, left (-100) to right (100), of the audio clip.Int32Adjusts the stereophonic balance of played audio.
Start positionDefines the start position of the further audio playbacks in percentages to the total duration of the currently selected audio clip.DoubleChanges at runtime affect the next playback only.
PositionIndicates the current playing position (in percentages to the total duration) of the audio clip. Changes are accepted only if the audio is currently playing.DoubleA change causes rewinding of the played audio to the new position.
Is PlayingReturns or sets the current playback state of the element. In the manual playback mode, the value can be set before the onset of the parent event. In all modes, the property can be used to control the currently playing audio: assigning false/true to the property causes pause/continuing the playback, correspondingly. System.Boolean
Runtime Status
Triggering TimeReturns the local event time in ms, when the last playback has reached the end. System.UInt64
Is TriggeredIndicates that the element has been triggered by end of the playback at least once, since the onset of the parent event. System.Boolean

+=== Properties inherited from clLibraryElement ===
NameDescriptionConstraintsValue TypeUpon Runtime Change
Material List
Selected IndexDefines the index of the active item in the material list of the element. Int32A change causes the current item to be reloaded and an update of the element.
Selected ItemDefines the name of the active item in the material list of the element. The name matches to a name of item in the Material Library StringA change causes the current item to be reloaded and an update of the element.
Item CountReturns the total number of items in the material list of the element.Int32
Equalize RGBThe property is only available in the visual element. If the value is true, the average RGB pixel intensity will be equalized across all items in the material list. You can turn on this property, when you need to obtain a luminance-balanced set of visual stimulus. Boolean

+=== Properties inherited from clElement === Inherited properties of clElement
NameDescriptionConstraintsValue TypeUpon Change
Control
Is EnabledIf set to false the element is completely omitted when the experiment is run.Boolean
TitleTitle of the element.String

ScrewTurn Wiki version 5.2.0.8. Some of the icons created by FamFamFam.