#include "stringinstrument.h"
+using namespace Qt;
+
// Images from http://www.asinari.it/bassoeng.htm
ViolinInstrument::ViolinInstrument(QWidget *parent)
{
noteStart = 48;
- // Set us up to look pretty
- setPaletteBackgroundPixmap(QPixmap("violin.png"));
- setFixedSize(637, 384);
- parentWidget()->setFixedSize(637,384);
+ background.load("violin.png");
setNotes(stringnote);
}
{
noteStart = 48;
- // Set us up to look pretty
- setPaletteBackgroundPixmap(QPixmap("viola.png"));
- setFixedSize(638, 392);
- parentWidget()->setFixedSize(638,392);
+ background.load("viola.png");
setNotes(stringnote);
}
{
noteStart = 36;
- // Set us up to look pretty
- setPaletteBackgroundPixmap(QPixmap("cello.png"));
- setFixedSize(639, 391);
- parentWidget()->setFixedSize(639,391);
+ background.load("cello.png");
setNotes(stringnote);
}
{
noteStart = 24;
- // Set us up to look pretty
- setPaletteBackgroundPixmap(QPixmap("contrabass.png"));
- setFixedSize(638, 388);
- parentWidget()->setFixedSize(637,384);
+ background.load("contrabass.png");
setNotes(stringnote);
}
: Instrument(parent)
{
// Set all the keys to false
- zeroArray(down);
- zeroArray(downFudge);
- zeroArray(bow);
- zeroArray(oldVolume);
- zeroArray(oldNote);
- zeroArray(note);
- zeroArray(volume);
-
- emitSounds();
+ memset(down, 0, sizeof(down));
+ memset(downFudge, 0, sizeof(downFudge));
+ memset(bow, 0, sizeof(bow));
+ memset(oldVolume, 0, sizeof(oldVolume));
+ memset(oldNote, 0, sizeof(oldNote));
+ memset(note, 0, sizeof(note));
+ memset(volume, 0, sizeof(volume));
+
+ QTimer::singleShot(50, this, SLOT(emitSounds()));
}
StringInstrument::~StringInstrument()
void StringInstrument::paintEvent(QPaintEvent *) {
QPainter paint(this);
+
+ paint.drawPixmap(0, 0, background);
+
paint.setPen(Qt::black);
for(int i = 0; i < 4; i++) {
break;
case Key_F12:
- zeroArray(down);
- zeroArray(bow);
- break;
+ memset(down, 0, sizeof(down));
+ memset(bow, 0, sizeof(bow));
+ break;
default:
e->ignore();
break;
case Key_F12:
- zeroArray(down);
- zeroArray(bow);
- break;
+ memset(down, 0, sizeof(down));
+ memset(bow, 0, sizeof(bow));
+ break;
default:
e->ignore();
QTimer::singleShot(50, this, SLOT(emitSounds()));
}
-void StringInstrument::zeroArray(bool array[4][4])
-{
- for(int i = 0; i < 4; i++) {
- for(int j = 0; j < 4; j++) {
- array[i][j] = false;
- }
- }
-}
-
-void StringInstrument::zeroArray(bool array[4])
-{
- for(int i = 0; i < 4; i++) {
- array[i] = false;
- }
-
-}
-
-void StringInstrument::zeroArray(int array[4])
-{
- for(int i = 0; i < 4; i++) {
- array[i] = 0;
- }
-}
-
-void StringInstrument::copyArray(int source[4], int dest[4])
-{
- for(int i = 0; i < 4; i++) {
- dest[i] = source[i];
- }
-}
-
void StringInstrument::emitSounds()
{
- copyArray(volume, oldVolume);
- copyArray(note, oldNote);
+ memcpy(oldVolume, volume, sizeof(oldVolume));
+ memcpy(oldNote, note, sizeof(oldNote));
- zeroArray(volume);
- copyArray(stringnote, note); // Fudge for setNotes(note);
+ memset(volume, 0, sizeof(volume));
+ memcpy(note, stringnote, sizeof(note)); // Fudge for setNotes(note);
// Need to find the differences in oldVolume, volume and oldNote, note
// Then stop changed notes, and start new ones