class Piano


Include Files

Description

This widget displays a piano keyboard.

Methods

Piano::Piano(int x, int y, int w, int h, const char *label = 0)

Creates a new Piano widget using the given position, size, and label string.

virtual Piano::~Piano()

Destroys the Piano widget and all of its data.

void notes (int n0, int n1)
int n0()
int n1()

Get and set the lowest and highest notes on the keyboard.  Notes are integers; zero is middle C, 12 is an octave above middle C, -12 is an octave below middle C.  If the values passed are black keys they will be changed to the adjacent white key.

void pos (int x)
int pos()

Get and set the position;  0 is horizontal,  1 is vertical.

int value()
void value (int x)
void value (double x)

Get and set the value, which is the number of the last key pressed.  The third form allows you to set to a floating-point value; this is useful for applications that allow in-between frequencies.  If the value is close to an integer, the piano will set its value to that integer.

static int nOE (int n)

Returns the note number mod 12, the "octave equivalent."

static int o8ve (int n)

Returns the number of octaves from the zero octave, which is note 0 to 11.  For example, o8ve(-11) = -1.

int n2y (float n)
int n2x (float n)
float y2n (int Y)
float x2n (int X)

These functions allow you to line up other widgets with a given note.