ViSi-Genie: Play Sound
Description
This Application Note explores the possibilities provided by ViSi-Genie for the Sounds object:
- Play
- Pause
- Stop
- Change volume
- And how to control the Sounds object by linking it to other objects.
This application note requires:
- Workshop4 has been installed as discussed here;
- The user is familiar with the Workshop4 environment and with the fundamentals of ViSi-Genie, as described in Workshop4 User Guide and ViSi-Genie User Guide;
- When downloading an application note, a list of recommended application notes is shown. It is assumed that the user has read or has a working knowledge of the topics discussed in these recommended application notes
Note
A ViSi-Genie project is provided as example to help you along this application note.
Downloadable Resources
The following are the sample project files for DIABLO-16 and PICASO.
Application Overview
Adding sound to a graphical user interface increases the user experience dramatically. 4D Systems screens feature a built-in speaker.
The application discussed in this application note is a fully featured music player:
ViSi-Genie makes building such an application as simple as click-and-drop elements on the screen.
This application note describes how to add a Sounds object and how to customise it.
Setup Procedure
This application note comes with a zip file which contains two ViSi-Genie projects.
For instructions on how to launch Workshop4, how to open a ViSi-Genie project, and how to change the target display, kindly refer to the section Setup Procedure of the application note:
- ViSi-Genie: Getting Started with PICASO Displays
- ViSi-Genie: Getting Started with DIABLO-16 Displays
Create a New Project
For instructions on how to create a new ViSi-Genie project, please refer to the section Create a New Project of the application note
- ViSi-Genie: Getting Started with PICASO Displays
- ViSi-Genie: Getting Started with DIABLO-16 Displays
The Sounds Object
You can load the example project files under the Downloadable Resources section or follow the procedures described hereafter.
Select the Home menu to display the objects:
The Sounds object is located on the System/Media pane:
Add a Sounds Object
Click on the Sounds icon to add it to the project.
This object is a non-visual widget and is only accessible via the Object Inspector.
The WYSIWYG screen remains unchanged and the Object Inspector shows the newly added Sounds0 object:
The Sounds0 object is empty and contains no tracks to play, as shown on the WavFiles property:
Add Tracks to the Sounds Object
Click on the WavFiles property.
A symbol appears. Click on it.
A new window WAV Files appears and shows all the tracks available:
For the moment, the list is empty.
To add a track, click on
The standard Windows Open file appears:
Select one WAV file, here 0011 Smooth, and click on Open.
The list of tracks is updated:
Repeat the procedure to add a second track, here 0002 Race against time and click on Open:
The list of tracks shows two files now, with their full paths:
To close the Wav Files window, click on
The WavFiles property of the Sounds0 object shows the same list:
Saving the project and selecting another object then going back to the Sounds0 object change the display of the names of the WAV files:
The WAV files are now referenced with their Windows short names.
Clicking on the of the WavFiles property shows the Wav Files window with the short names:
Sort the Tracks
To sort the list, click on the track you want to move, here 0002_r!2.wav on line 2:
Click on the button Up or
Down
to sort the list
Delete a Track
To delete a track, select it and press Delete:
Note that there is no confirmation dialog when deleting the track since the changes is only applied when the
OK button is pressed.
If a track is mistakenly deleted, press the Cancel
button to quit the Wav Files window without taking into account the modifications and then open it again, or
simply readd the image before pressing OK
.
Control the Sounds Object
Add five Button objects, a TrackBar and a Label objects to the form, and customise their appearance properties as you like, in order to obtain the following screen:
Each object, among the buttons and the track-bar, when it is pressed and released, sends a specific command to the Sounds object.
The hidden Sounds object has the following properties and 2 tracks:
Select and Play a Track
Because Sounds0 has 2 tracks, there are two buttons to select each of them.
Winbutton0 selects the first track
and when pressed and released, the onChanged event is raised and sends the command Sounds0Tune0:
The command Sounds0Tune0 stands for Tell the Sounds0 object to play the track 0.
Please note the first track is numbered 0, the second 1 and so on.
To select the second track, the WinButton4 button
sends the command Sounds0Tune1:
The command Sounds1Tune0 stands for Tell the Sounds0 object to play the track 1.
Pause
To pause playing the track, the WinButton3 button
sends the command Sounds0Pause:
The command Sounds0Pause stands for Tell the Sounds0 object to pause playing the track.
Resume After Pause
To resume playing the track being paused, the WinButton1 button
sends the command Sounds0Play:
The command Sounds0Play stands for Tell the Sounds0 object to resume playing the track being currently paused.
Stop
To stop playing the track, the WinButton1 button
sends the command Sounds0Stop:
The command Sounds0Stop stands for Tell the Sounds0 object to stop playing the track.
Contrary to the Sounds0Pause command which has a resume command with Sounds0Play, there is no resume command. A new Sounds0Tune0 or Sounds0Tune1 command is needed to start playing the track again.
Control the Volume
The TrackBar object allows controlling the volume:
When pressed and released, the onChanged event is raised and sends the command Sounds0Volume:
The command Sounds0Volume stands for Tell the Sounds0 object to set volume to the value sent.
Minimum volume is 0 and maximum is 100, so the TrackBar should be defined accordingly:
Build and Upload the Project
For instructions on how to build and upload a ViSi-Genie project to the target display, please refer to the section Build and Upload the Project of the application note
- ViSi-Genie: Getting Started with PICASO Displays
- ViSi-Genie: Getting Started with DIABLO-16 Displays
The uLCD-32PTU and/or the uLCD-35DT display modules are commonly used as examples, but the procedure is the same for other displays.
Summary
Element | ViSi-Genie | Command | Comment |
---|---|---|---|
Tracks | hidden | ![]() |
Sounds object. Click on ![]() ![]() |
Play | ![]() |
![]() ![]() |
Simple WinButton object |
Pause | ![]() |
![]() |
Simple WinButton object |
Resume | ![]() |
![]() |
Simple WinButton object |
Stop | ![]() |
![]() |
Simple WinButton object |
Volume | ![]() |
![]() |
TrackBar object ![]() |