Music Module

MusicMainScreen

This module allows you to play audio files of the Smartphone by sending the command from your hardware board.

Here you create different music tiles of different key names. With each key name, you associate a music file from your Smartphone. Later you send commands containing these key names from hardware and as per the key names received in the app music file of associated key name is being played. There are two ways in which a file can be played:

  1. Play a file immediately
  2. Play files one by one in a queue.

Introduction

The Music module allows you to play tones, songs and other recorded audio files from your phone’s storage as per command send from the hardware device. You can send the command to play or stop an audio file. You can also give commands to play various audio files one by one in a queue.

Follow the steps below to play different audio files from this module:

  1. As you open the music module you can see three tiles on the screen. Two tiles are named A4 and B4 and one tile has ‘+’ mark on it. On clicking A4 or B4 tile, some music will be played. Here A4 and B4 are keys associated with those music files. You can add your own key tile by clicking on the tile marked ‘+’. This tile is an added tile.MusicMainScreen
  2. To add audio files of your own choice click on Add tile. You can see a screen as shown below. There you can see a message above the text box “Enter a key and select audio files” informing you to enter the key name and then select a music file. MusicEnterKey1
  3. You can select audio file either from the list provided below or from your phone storage. To select an audio file from phone storage scroll at the bottom of the list and select “Tap here to see music from device”.MusicTapForFile
  4. You will be asked for permission to access media files. Select “Allow” and proceed.MusicPermission
  5. You would see two different sections named “Default” and “Device” containing various music files.
  6. Enter a key name say “D2” and select an audio file. As soon as you do this a new tile named “D2” is created and when you click on that tile your selected audio file will be played.MusicEnteredKey MusicNewTileAdded
  7. You can also delete any music tile by doing a long press on that tile.MusicDelete
  8. In order to play these files from your hardware, you have to send these key names from your hardware. How to do this? It will be more clear from the explanations and examples as given below.

Arduino IDE Functions

Header

To include the GamePad module in the Arduino program, you have to include the following header:

#define CUSTOM_SETTINGS

#define INCLUDE_MUSIC_MODULE

After defining the above mention headers, you have to include the dabble library:

#include <Dabble.h>

You can download the zip of Arduino Library for

  1. evive, Uno, Mega, and Nano – Dabble-Arduino 
  2. ESP32 – Dabble-ESP32

depending on the board you are using.

Enabling Bluetooth Communication

To enable Bluetooth communication, you have to initialize serial communication using the following code:

  1. For evive and Arduino Mega, Uno and Nano
    Dabble.begin(Baud_Rate);

    Here Baud_Rate is the baud rate set for the Bluetooth module. With evive, you normally get 115200 baud rate modules.

  2. For ESP32
    Dabble.begin("Bluetooth_Name");

    In place of Bluetooth_Name  enter name that you want to keep for Bluetooth of ESP32. Default name given in the library is “MyEsp32”. 

Refreshing the data

To refresh the data that the device has got from the mobile app, you have to use the following line of code:

Dabble.processInput();

Functions

Music.play(key) – This function immediately plays the file with the key name passed as argument in it.

Music.addToQueue(key) – This function instructs the phone to play music associated with the key only after the completion of any ongoing music file. By using this command multiple times, you can create a list of various music files and play them one by one.

Music.stop() – Stop playing all the music files.

PictoBlox (Scratch) Blocks

There are two blocks available for music module in PictoBlox.MusicPlay

The “() music file ()block is used to play the audio file for the key entered in the text box of the block. The drop -down of this block has two options :

  1. play – Selecting this option means the music file written in the block will be immediately played as soon as the block is executed.
  2. add to Queue – Selecting this option means the music file written in the block will be executed only after completing playing the ongoing music file.MusicStop

stop music” this block stops all the music file that is played from mobile.

evive Notes Icon
Note: When you are using this module with Arduino Uno, Mega, and Nano,  you have to set the Bluetooth baud rate to the baud rate of the Bluetooth module to have proper communication between the board and the module. To set the baud rate you have to use set bluetooth baud rate to () block.

set bluetooth baud rate to

Examples

Click here to view Arduino IDE Example for Music Module

evive

Mega, Uno, and Nano

ESP32

Click here to view PictoBlox (Scratch) Example for Music Module

eviveMusicModule_evive

UNO

MusicModule_UNO

For Arduino Mega or Nano you would change the head block. Currently, PictoBlox does not support ESP32 but it’s support will be added soon.

Projects

All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart