Skip to content

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.

PICASO DIABLO-16

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:

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.

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:

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

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:

Home Menu

The Sounds object is located on the System/Media pane:

System/Media pane

Add a Sounds Object

Click on the Sounds Icon 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:

Object Inspector

The Sounds0 object is empty and contains no tracks to play, as shown on the WavFiles property:

WavFiles

Add Tracks to the Sounds Object

Click on the WavFiles property.

WavFiles property

A Symbol symbol appears. Click on it.

A new window WAV Files appears and shows all the tracks available:

WAV Files Window

For the moment, the list is empty.

To add a track, click on

Add

The standard Windows Open file appears:

Open Window

Select one WAV file, here 0011 Smooth, and click on Open.

The list of tracks is updated:

Wav Files

Repeat the procedure to add a second track, here 0002 Race against time and click on Open:

Open

The list of tracks shows two files now, with their full paths:

Wav Files

To close the Wav Files window, click on

OK

The WavFiles property of the Sounds0 object shows the same list:

WavFiles Properties

Saving the project and selecting another object then going back to the Sounds0 object change the display of the names of the WAV files:

Wav Files

The WAV files are now referenced with their Windows short names.

Clicking on the Symbol of the WavFiles property shows the Wav Files window with the short names:

WavFiles Window

Sort the Tracks

To sort the list, click on the track you want to move, here 0002_r!2.wav on line 2:

0002_r!2.wav

Click on the button Up Up or Down Down to sort the list

WavFiles

Delete a Track

To delete a track, select it and press Delete: Delete

Note that there is no confirmation dialog when deleting the track since the changes is only applied when the OK OK button is pressed.

If a track is mistakenly deleted, press the Cancel 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 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:

Music Player

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:

Object Inspector

Select and Play a Track

Because Sounds0 has 2 tracks, there are two buttons to select each of them.

Winbutton0 selects the first track

Winbutton

and when pressed and released, the onChanged event is raised and sends the command Sounds0Tune0:

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

Winbutton4

sends the command Sounds0Tune1:

Object Inspector

The command Sounds1Tune0 stands for Tell the Sounds0 object to play the track 1.

Pause

To pause playing the track, the WinButton3 button

Winbutton3

sends the command Sounds0Pause:

Object Inspector

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

Winbutton1

sends the command Sounds0Play:

Object Inspector

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

Winbutton1

sends the command Sounds0Stop:

Object Inspector

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:

TrackBar

When pressed and released, the onChanged event is raised and sends the command Sounds0Volume:

Object Inspector

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:

Minimum volume

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

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 WinButton0 Sounds object. Click on Symbol to open the Wav Files window, then Add the tracks
Play CheckBox Button Off Button On Simple WinButton object
Pause Radio-Button Option Simple WinButton object
Resume Button Button Simple WinButton object
Stop Stop WinButton0 Simple WinButton object
Volume TrackBar WinButton0 TrackBar object Maxvalue