Example Code

LabVIEW - Metronome Example

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

This is an example of a metronome using a producer/consumer (events) architecture.

Description

For all the rhythmically challenged LabVIEW developers - here is an example of a metronome.  This example was developed using a producer/consumer (events) architecture and makes use of 2 of the new features included in LabVIEW 2011.  Namely the controls from the Silver palette and asynchronous call by reference.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Run the VI and click on Start.
  2. Click on the 4 buttons between "Start" and "Stop" to increase/decrease the BPM.
  3. Change Beats Per Cycle and Accented beats to set the tone of the beep (i.e. "high-low-low-low")

 

Additional Information or References

Front Panel

FrontPanel.png

 

Block Diagram

BlockDiagram.PNG

 

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**


Regards,

Peter D

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
PointOnePa
Member
Member
on

What's is suppose to do? Could not get beats per minute to change.

Not clear what Accented Beats is suppose to do.

Pete.Dunc
Active Participant
Active Participant
on
  • The meter flicks right to left - clicking each time the dial passes the centre.  Just like a traditional metronome.
  • Accented beats sets the tone of the beep.  In the image it would be "high-low-low-low-high-low-low-low"

Regards,

Peter D

PointOnePa
Member
Member
on

Yes, I know what a metronome does, but it wasn't clear what the accented beats is doing (thanks for the clarification)

or why the "beats per minute" doesn't change and appears to be fixed.

Pete.Dunc
Active Participant
Active Participant
on

Good question - my documentation is lacking in this example

The 4 buttons between "Start" and "Stop" are used to increase/decrease the BPM.  The number shown is a display of the current value and is not used to edit the speed.


Regards,

Peter D

PointOnePa
Member
Member
on

Ah, okay...I guess I'm not use to the "silver" controls as I thought those arrows were disabled because of their faded color.  Now it makes more sense.  Note, since Metronome.vi is setup as a dialog windows instead of the default (presumedly to get read of the runtime start/stop), you can't easily debug in the block diagram while it is running....I set it back to "Top Level Window".   Curious that you can start the metronome but can't stop it without stopping the entire VI.  Also curious that the "Beats Per Minute" wraps around from 0, to 255...was that intended?

Pete.Dunc
Active Participant
Active Participant
on
  • The code could be modified to return to the initialise state rather than stop the code altogether.
  • Beats Per Minute will wrap from 0 to 255 as it is a U8 - this is intended to minimise checking for out of range beats.

Regards,

Peter D

Alex.T
Active Participant
Active Participant
on

Pete this is cool!

The asynchronous call to the sound playing VI is a really good idea.


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)