Facebook Pixel

AN-00053 Designer or ViSi Playing Sound

Description This application note presents and discusses a Designer project for playing a WAV audio file. The 4DGL code of the Designer project can be copied and pasted to an empty ViSi project and it will compile normally. The code can also be integrated to that of an existing ViSi project.
Supported Processor PICASO, DIABLO16
Supported Environment Designer, ViSi
Difficulty Easy

 

File Downloads
Files

Description

This application note presents and discusses a Designer project for playing a WAV audio file. The 4DGL code of the Designer project can be copied and pasted to an empty ViSi project and it will compile normally. The code can also be integrated to that of an existing ViSi project.

Before getting started, the following are required:

  • Any of the following 4D Picaso display modules:

        gen4-uLCD-24PT

        gen4-uLCD-28PT

        gen4-uLCD-32PT

        uLCD-24PTU

        uLCD-28PTU

        uVGA-III 

and other superseded modules which support the ViSi Genie environment

  • The target module can also be a Diablo16 display

        gen4-uLCD-24D series

        gen4-uLCD-28D series

        gen4-uLCD-32D series

        gen4-uLCD-35D series

        gen4-uLCD-43D series

        gen4-uLCD-50D series

        gen4-uLCD-70D series

        uLCD-35DT

        uLCD-43D Series

        uLCD-70DT 

Visit www.4dsystems.com.au/products to see the latest display module products that use the Diablo16 processor. The display module used in this application note is the uLCD-32PTU, which is a Picaso display. This application note is applicable to Diablo16 display modules as well.

 

Application Overview

The Picaso and Diablo16 are range of display modules equipped with a small speaker and an audio amplifier chip, which is capable of playing a WAV file from the uSD card. This application note will walk through the necessary steps to playback audio from a WAV file source on a 4D Picaso or Diablo16 display module. Once it is known how to produce these sounds, they can then be linked to such actions as a touch, received serial data, or when an image is displayed.

 

Setup Procedure

For instructions on how to launch Workshop 4, how to open a Designer project, and how to change the target display, kindly refer to the section “Setup Procedure” of the application note

Designer Getting Started - First Project

For instructions on how to launch Workshop 4, how to open a ViSi project, and how to change the target display, kindly refer to the section “Setup Procedure” of the application note

ViSi Getting Started - First Project for Picaso and Diablo16

 

Create a New Project

For instructions on how to create a new Designer project, please refer to the section “Create a New Project” of the application note

Designer Getting Started - First Project

For instructions on how to create a new ViSi project, please refer to the section “Create a New Project” of the application note

ViSi Getting Started - First Project for Picaso and Diablo16

 

Design the Project

Preparing the µSD Memory Card

In order to play a custom sound through a module, a µSD card must first be sourced for storing the WAV file. The first step is to format the µSD to FAT16 or FAT (Default). Insert the card into a PC and right click on the µSD card and select Format. Leave all settings as they appear, or change them accordingly as shown in the snapshot below. Press the Start button and the card will now be formatted.

 

Loading an Appropriate WAV File

Now that the µSD card is formatted, it is ready to have the desired WAV file loaded onto it. Use any audio editing software to save the sound as a 16kHz Mono WAV file to your µSD card. Try and get as close to this frequency as possible, however, the extreme most thresholds are 22kHz and 12kHz. Anything outside these boundaries won’t work. Insert the µSD card into the module and open Workshop to begin code development.

Essential commands for Producing Audio

To play a sound file at the most basic level, all that is required is mounting the drive and playing the WAV file. The following extract shows the necessary commands:

Potential Issues

However, these commands alone are prone to improper use and potential errors. It is recommended that the following issues be addressed when dealing with these commands.

  • µSD not inserted
  • File not on the µSD card
  • Incorrect volume level
  • Not enough time to play the whole duration of the file

Functions to Combat Issues

Here is a list of functions available to combat these problems:

  • file_Mount()
  • file_Exists(fname)
  • snd_Volume(var)
  • snd_Playing()

Simple Example

The next snippet of code takes into account such possible issues:

Complete Application Example

Finally, a fully scripted example is shown that includes error messages for any potential issues that may be encountered:

For detailed instructions on how to manipulate sound with your Picaso or Diablo16 device, please refer to the separate documents:

Picaso Internal Functions Manual

or

Diablo16 Internal Functions Manual.

Build an External Speaker Circuit (for gen4 Displays)

Unlike the non-gen4 modules, the gen4 Displays do not have an on board speaker. Users may consult this circuit as a reference for building their own.

Run the Program

For instructions on how to save a Designer project, how to connect the target display to the PC, how to select the program destination, and how to compile and download a program, please refer to the section “Run the Program” of the application note

Designer Getting Started - First Project

For instructions on how to save a ViSi project, how to connect the target display to the PC, how to select the program destination, and how to compile and download a program, please refer to the section “Run the Program” of the application note

ViSi Getting Started - First Project for Picaso and Diablo16

The uLCD-32PTU and uLCD-35DT display modules are commonly used as examples, but the procedure is the same for other displays.

 

Share: