Facebook Pixel

AN-00006 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.
Supported Processor PICASO, Diablo16
Supported Environment ViSi-Genie
Difficulty Medium

 

File Downloads
Files

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:

  • Workshop 4 has been installed according to the document Workshop 4 Installation;
  • The user is familiar with the Workshop 4 environment and with the fundamentals of ViSi-Genie, as described in Workshop 4 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.

A ViSi-Genie project is provided as example to help you along this application note.

 

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 Workshop 4, 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 – First Project for Picaso Displays (for Picaso) 

or

ViSi Genie Getting Started – First Project for Diablo16 Displays (for Diablo16).

 

Create a New Project

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 – First Project for Picaso Displays (for Picaso)

or

ViSi Genie Getting Started – First Project for Diablo16 Displays (for Diablo16).

 

The Sounds Object

The Sounds Object

You can load the ViSi-Genie project example…

Example:  4D-AN-00006 PICASO or 4D-AN-00006 DIABLO16

…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 first on the Sounds icon…

…and there is no need to click on the WYSIWYG screen to place it as the Sounds object is a hidden object.

If the WYSIWYG screen remains unchanged, 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.

 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

 

…and the list is sorted:

 

The reverse for Up is the Down button

Delete a Track

To delete a track, select it and press Delete:

Caution: there is no confirmation dialog.

 

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:

 

 

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 – First Project for Picaso Displays (for Picaso)

or

ViSi Genie Getting Started – First Project for Diablo16 Displays (for Diablo16).

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

 

 

 

 

Share: