Database Player

ID:  2008

Object Description

The Database Player object is used to select and play wave files identified in a database (also see object 2054). Static data is used to configure the database filename and table name as well as the device channel the wave files are played on. Dynamic controls for the player include volume, frequency, wave file identifier, loop enable, and play enable. An output pin provides a Boolean play status of the wave file.

The database can be constructed with any database tool capable of ODBC (Open DataBase Connectivity) interoperability. One table exists in the database with three columns defined as follows (ensure that the KEY field has no duplicate entries):

The name of an ODBC data source needs to be established in order for the Database Player to open it and find the table. This Data Source Name (DSN) must match the Database Name set in static data. The name of the table in the database must match the Table Name also set in static data. The Table Name must NOT contain any blank characters.

To set the ODBC Data Source Name:

Input Pins

VOL

The VOL pin control the audio output level of this object. The valid range of this parameter is 0.0 (no volume) to 1.0 (full volume).

FREQ

The FREQuency pin is a factor multiplied with the original sampling rate of the wave file to produce a rate at which the file will play. The sampling rate can range from 0 to 100,000. Normally, wave files have a sampling rate of 44,100 or 22,050 Hz. A factor of 2 would cause this object to change the sampling rate to 88,200, effectively doubling the pitch. A factor of 0 will essentially stop the player since this would equate to 0 samples per second. This pin can be used to "pitch bend" the audio while it is playing.

ID

The ID pin value maps to the index field in the database and identifies the wave file to be played. This number can be changed during run-time without stopping execution.

Note: Wait at least two frames between value changes on this pin. Otherwise, the new wave file will not be loaded and played.

 

loop

This pin will enable looping with any non-zero value. If the pin is 0, the wave file will play once and stop.

ENABLE

The ENABLE pin is used to turn the object on or off. The player is activated with any non-zero value. If the object is playing, returning this input to zero will stop the player.

Output Pins

PLAY POS

The PLAY POS pin produces a 1 when the wave file is playing, and a 0 if the wave file has stopped playing.

Static Data

Channel

This is the channel number of the audio output device. This number is assigned by the Platform Configure dialog box in the V+ Run Time System and indicates which audio output device this object is to use for playing the wave file.

To set the Channel:

More about Devices and Channels:

Database Name

The DSN corresponding to the database containing the wave file names.

To set the Database Name:

Table Name

The name of the database table containing the wave file names. This name must NOT contain any blank characters.

To set the Table Name:

Example

The example below demonstrates the use of the Database Player. It is playing a wave file from the VPLusDatabasePlayerWavefiles table within the VPLus Database Player database. The ID selected is 5 which maps to the Helicopter 45.wav file. The screenshot below the example is from the Microsoft Access database VPLus Database Player.mdb. It lists all the files to be played by the Database Player. The VPLus Database Player.mdb file resides in the C:\Program Files\VPLus\VPLus Help Examples directory.

 

VPLusDatabasePlayerWavefiles Table Data