From d388324e7b91bdd95553c3849d77cddd5bd0bfc4 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Tue, 20 Jan 2004 13:07:31 +0000 Subject: initial import of powerchord courtesy Camilo Mesias modified some bits to be compatible with the opie build system packaging not complete yet i hope camilo will maintain this here... --- diff --git a/noncore/multimedia/powerchord/README b/noncore/multimedia/powerchord/README new file mode 100644 index 0000000..b617f73 --- a/dev/null +++ b/noncore/multimedia/powerchord/README @@ -0,0 +1,117 @@ +This tarball is a collection of the sources of Powerchord as a work in progress. It is provided to fulfil the conditions of the GPL. + +-Cam 15 Apr 2002 camilo@mesias.co.uk + + +These files are the ones I used to make the release 0.0.7 of Powerchord. + +Originally I had intended to release under the GPL, then under pressure of time I wanted to release as closed-source freeware, to be relicensed at a later date. For simplicity though, I have opted to provide this crude tarball and release from the start under the GPL. + +Some of the source files do not contain the proper copyright notice yet. + +// Copyright (c) 2001 Camilo Mesias +// camilo@mesias.co.uk +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +The make system is not foolproof. + +Under pressure of time I abandoned using designer and carefully hacked code into auto-generated files. I plan to go back to designer and learn how to insert these bits of code in a way that is in harmony with the original Trolltech example make files. + +Credits. +This is all my own work, with the exception that some of it is derived from the Trolltech example code. The chord algorithm was originally written in Javascript by Jim Cranwell and is used with his permission. Some of the code dates back to the original version of Powerchord that I wrote for the Agenda VR3. That was my first Agenda app and was in turn related to the code for the Agenda Power Meter application. Some of the original Agenda (fltk) include directives remain in the code, commented out... The name derives from the use of the Agenda Power application as a starting point. Power + Chord = Powerchord. Credit to a number of web resources on computing music, especially the first one I read that talked about the 12th root of 2! Credit finally to 4Front Technologies, their document 'Open Sound System - A Programmers' Guide' was most useful. This is my first use of OSS. + +Here is a breakdown of the essential parts of this archive: + +README +TODO +Makefile + +MANUAL.html -- webpage stuff +index.html +display.png +tuning.png + +powerchord.control -- control file for .ipk +powerchord.desktop -- Qtopia desktop file +powerchord.pro -- input for tmake +powerchord.ui -- input for Designer +powerchordbase.ui -- input for Designer + +Powerchord.png -- icon + +RCS -- some files under RCS + +acguitar.raw -- assorted audio files +long.acguitar.raw + +amp_but.png -- assorted image files +audio.png +blank_but.png +chordshow.png +image0.xpm +image1.png +image2.png +image3.png +image4.png +image5.png +image6.png +image_open.png +mic-closed.png +mic-open.png +mic-open.xpm +wood.png +wood_s.png +x.png +z1.png +z2.png +stringfing_s.png +transport-blank.png +transport-fwd.png +transport-play.png +transport-rec.png +transport-rev.png +powerchord-pics + +chordengine.cpp -- code to make chords +chordengine.h + +fretboard.cpp -- widget to display fret board +fretboard.h + +gs.cpp -- guitar synth (audio) code +gs.h + +gt.cpp -- guitar tuner (audio) code - not finished +gt.h + +powerchord.cpp -- framework code - like main +powerchord.h + +powerchordbase.cpp -- main GUI code hacked from the designer generated one +powerchordbase.h + +vumeter.cpp -- vu-meter lookalike widget for tuner +vumeter.h + +install.sh -- instructions to build the .ipk and install it + +main.cpp -- token main() + +moc_fretboard.cpp -- generated files, do not touch! +moc_powerchord.cpp +moc_powerchordbase.cpp +moc_vumeter.cpp + diff --git a/noncore/multimedia/powerchord/TODO b/noncore/multimedia/powerchord/TODO new file mode 100644 index 0000000..9eb5906 --- a/dev/null +++ b/noncore/multimedia/powerchord/TODO @@ -0,0 +1,4 @@ +save chords +replay saved chords +help +check out submission diff --git a/noncore/multimedia/powerchord/chordengine.cpp b/noncore/multimedia/powerchord/chordengine.cpp new file mode 100644 index 0000000..d8c3c4e --- a/dev/null +++ b/noncore/multimedia/powerchord/chordengine.cpp @@ -0,0 +1,297 @@ +// +// ChordEngine class to calculate chords +// + +// Copyright (c) 2001 Camilo Mesias +// camilo@mesias.co.uk +// +// derived from JavaScript code by Jim Cranwell, used with permission +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +#include + +#include + +#include "chordengine.h" + +ChordEngine::ChordEngine(){ + + string[0] = OPEN; + string[1] = OPEN; + string[2] = OPEN; + string[3] = OPEN; + string[4] = OPEN; + string[5] = OPEN; + + base_note = 0; + chord_type = 0; + fret_pos = OPEN; + span_size = 1; + variation = 7; + tuning = 0; + + js_tunit(tuning); + js_whatchord(chord_type); + js_vboy(variation); + + label_text[0] = 0; +} + +int ChordEngine::finger(int f){ + return string[f]; +} +#define BREAK (401) +void ChordEngine::calculate(){ + + sprintf(label_text, "%s %s %s%s", + notes[base_note], + (chord_type)?keys[chord_type]:"", + (fret_pos==OPEN)?"":"fret-", + (fret_pos)?frets[fret_pos]:""); + + string[0] = + string[1] = + string[2] = + string[3] = + string[4] = + string[5] = MUTED; + + for (int in=0;in<6;in++){ + notename[in]=0; + } + + js_tunit(tuning); + // js_MMM[0] = 4; + //js_MMM[1] = 9; + //js_MMM[2] = 2; + //js_MMM[3] = 7; + //js_MMM[4] = 11; + //js_MMM[5] = 4; + + int js_D = base_note; + + int js_Q = span_size; + + js_Q += 2; + + int js_V = variation; + + int js_FR = fret_pos; + + int js_G = 0; + + int js_A = 0; + + if (js_FR){ + js_G = 8; + } + + js_L = 1; + js_Y = 1; + js_Z = 1; + + js_vboy(variation); + + js_Y += js_Q; + int js_K = 0; + int js_W = js_D - js_Z; + int js_H = -js_Z; + int js_N[6] = {0, 0, 0, 0, 0, 0}; + int js_TCK[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int js_E = 0; + int js_X = 0; + + for (int j=0; j<41; j++){ + js_A = 0; + for (int b=0; b<7; b++){ + if (js_N[b] == 1){ + js_A++; + } + if ((js_A==6)||(j>39)){ + for (int i=0; i<12; i++){ + if (js_TCK[i] != js_T[i]){ + memset((void *)js_N, 0, 6*sizeof(int)); + memset((void *)js_TCK, 0, 12*sizeof(int)); + js_V++; + js_X++; + if (js_V>23){ + js_V = 0; + } + js_vboy(js_V); + j = 0; + i = BREAK; + b = BREAK; + if (js_X > 23){ + js_N[0] = js_N[1] = js_N[2] = js_N[3] = js_N[4] = js_N[5] = 1; + j = BREAK; + } + } + } + } + } + int js_S = 0; + js_W = (js_W + js_Z)%12; + js_H = (js_H + js_Z)%12; + + while (js_S < js_Y){ + js_S++; + if (js_E > js_Q){ + js_E = 0; + js_K = (js_K + js_L)%6; + } + if (js_E<0){ + js_E = js_Q; + js_K = (js_K + js_L)%6; + } + if (js_T[js_H] == 0){ + for (int c=0;c<13;c++){ + js_W = (js_W+js_Z)%12; + js_H = (js_H+js_Z)%12; + if (js_T[js_H] == 1){ + c=BREAK; + } + } + } + if (js_N[js_K] == 1){ + for(int b=0; b<7; b++){ + js_K = (js_K+js_L)%6; + if(js_N[js_K] == 0){ + b = BREAK; + } + if(b==6){ + js_S = BREAK; + } + } + } + + // js_K is the index of the string + // js_MMM is the base note played by that string in the current tuning + // js_FR is the fret position + // js_E + // js_F represents the note made by this string here + // js_N[] records if we have found a finger position for this string + // js_W - represents the note we want???? + + int js_F = (js_MMM[js_K]+js_E+js_FR)%12; + + if ((js_W==js_F)&&(js_N[js_K]==0)){ + + int js_EG = js_E+js_G; + + string[js_K] = js_EG; + notename[js_K] = notes[js_W]; + + js_N[js_K] = 1; + js_TCK[js_H] = 1; + js_S = BREAK; + } + js_E += js_VM; + + } + + } + +} + + +const int ChordEngine::alt_tunings[][6] = { + {4, 9,2,7,11,4}, + {4,11,4,8,11,4}, + {4, 9,4,9, 1,4}, + {4, 9,2,6,11,4}, + {4, 9,2,7, 0,5}, + {2, 9,2,7, 9,2}, + {2, 7,0,7, 0,2}, + {2, 9,2,6, 9,2}, + {2, 9,2,7,11,4}, + {2, 7,2,7,11,2}, + {2, 9,2,9, 0,2}, + {0, 7,0,7, 9,4}, + {5, 9,2,7,11,4}, + {7,10,2,7,10,2}, +}; + +void ChordEngine::js_tunit(int t){ + int max=0; + int octave=0; + for (int i=0;i<6;i++){ + js_MMM[i] = ChordEngine::alt_tunings[t][i]; + if (js_MMM[i] < max){ + octave += 12; + } + max = js_MMM[i]; + note_indices[i] = octave + js_MMM[i]; + } +} + +const int ChordEngine::chordbases[][12] = { + {1,0,0,0,1,0,0,1,0,0,0,0}, // maj + {1,0,0,1,0,0,0,1,0,0,0,0}, // min + {1,0,0,0,1,0,0,1,0,0,1,0}, // 7th + {1,0,0,1,0,0,0,1,0,0,1,0}, // m7 + {1,0,0,0,1,0,0,1,0,0,0,1}, // maj7 + {1,0,0,0,1,0,0,1,0,1,0,0}, // 6th + {1,0,0,1,0,0,0,1,0,1,0,0}, // m6th + {1,0,0,0,1,0,0,0,1,0,0,0}, // aug + {1,0,0,1,0,0,1,0,0,1,0,0}, // dim + {1,0,0,0,0,1,0,1,0,0,0,0}, // sus4 + {1,0,0,0,0,1,0,1,0,0,1,0}, // 7sus4 + {1,0,1,0,1,0,0,1,0,0,1,0}, // 9th + {1,0,1,0,1,0,0,1,0,0,0,0}, // add9 + {1,0,1,1,0,0,0,1,0,0,1,0}, // m9th + {1,1,0,0,1,0,0,1,0,0,0,1}, // maj9 + {1,0,1,0,0,0,0,1,0,0,0,0}, // sus2 + {1,0,1,0,0,0,0,1,0,0,1,0}, // 7sus2 + {1,0,1,0,0,1,0,1,0,0,1,0}, // 11th + {1,0,1,1,0,1,0,1,0,0,1,0}, // m11th + {1,0,0,0,1,0,0,1,0,1,1,0}, // 13th + {1,0,0,1,0,0,0,1,0,1,1,0}, // m13th + {1,0,0,1,0,0,0,1,0,1,0,1}, // maj13 + {1,0,1,0,1,0,0,1,0,1,0,0}, // 6/9 + {1,0,0,0,1,0,1,0,0,0,0,0}, // flat5 + {1,0,0,1,1,0,0,0,0,0,1,0}, // 7#9 + {1,0,0,1,0,0,1,0,0,0,1,0}, // Ø7 + {1,0,0,0,0,0,0,1,0,0,0,0}, // 5 +}; + +void ChordEngine::js_whatchord(int c){ + for (int i=0;i<12;i++){ + js_T[i] = ChordEngine::chordbases[c][i]; + } +} + +void ChordEngine::js_vboy(int v){ + js_L = ((v/3)%2)?5:1; + js_Y = ((v/6)%2)?45:4; + js_Z = (v%3 == 0)?1:(v%3 == 1)?7:11; + js_VM = ((v/12)%2)?-1:1; +} + +const char* ChordEngine::notes[] = {"C", "C#", "D", "Eb", "E", "F", "F#", "G", "G#", "A", "Bb", "B", 0}; + +const char* ChordEngine::keys[] = {"maj", "min", "7th", "m7", "maj7", "6th", "m6th", "aug", "dim", "sus4", "7sus4", "9th", "add9", "m9th", "maj9", "sus2", "7sus2", "11th", "m11th", "13th", "m13th", "maj13", "6|9", "flat5", "7#9", "Ø7", "5", 0}; + +const char* ChordEngine::frets[] = {"open", "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th", 0}; + +const char* ChordEngine::variations[] = {"V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10", "V11", "V12", "V13", "V14", "V15", "V16", "V17", "V18", "V19", "V20", "V21", "V22", "V23", 0}; + +const char* ChordEngine::tunings[] = {"EADGBE", "EBEG#BE", "EAEAC#E", "EADF#BE", "EADGCF", "DADGAD", "DGCGCD", "DADF#AD", "DADGBE", "DGDGBD", "DADACD", "CGCGAE", "FADGBE", "Gminor",0}; + + + + + diff --git a/noncore/multimedia/powerchord/chordengine.h b/noncore/multimedia/powerchord/chordengine.h new file mode 100644 index 0000000..44b7388 --- a/dev/null +++ b/noncore/multimedia/powerchord/chordengine.h @@ -0,0 +1,124 @@ +// +// ChordEngine class to calculate chords +// + +// Copyright (c) 2001 Camilo Mesias +// camilo@mesias.co.uk +// +// derived from JavaScript code by Jim Cranwell, used with permission +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +#ifndef __CHORDENGINE_H +#define __CHORDENGINE_H + +#include + +class ChordEngine; + +class ChordEngine { + + private: + //saved state + + int base_note; + int chord_type; + int fret_pos; + int span_size; + int variation; + int tuning; + + int string[6]; + const char *notename[6]; + + // unfathomable stuff ported from javascript: js_prefix + // may ask Jim Cranwell if he'd like to comment on it + int js_MMM[6]; + int note_indices[6]; + + void js_tunit(int t); + + int js_T[12]; + + void js_whatchord(int c); + + int js_L, js_Y, js_Z, js_VM; + + void js_vboy(int v); + + // stuff I put in + char label_text[20]; + static const int chordbases[][12]; + static const int alt_tunings[][6]; + + public: + static const char* notes[]; + static const char* keys[]; + static const char* frets[]; + static const char* variations[]; + static const char* tunings[]; + + + static const int OPEN = 0; + static const int MUTED = 7; + + ChordEngine(); + + // accessors + const char *name(int f){return notename[f];}; + int noteindex(int f){ + if (string[f] == MUTED){ + return -1; + }else{ + return note_indices[f] + string[f]; + } + }; + + void base(int b){base_note = b;}; + int base(){return base_note;}; + + void chord(int c){chord_type = c; js_whatchord(c);}; + int chord(){return chord_type;}; + + void fret(int f){fret_pos = f;}; + int fret(){return fret_pos;}; + + void span(int s){span_size = s;}; + int span(){return span_size;}; + + void vary(int v){variation = v; js_vboy(v);}; + int vary(){return variation;}; + + void tune(int t){tuning = t; js_tunit(t);}; + int tune(){return tuning;}; + + // methods + void calculate(); + + const char *label(){return label_text;}; + + int finger(int string); // returns fret position or MUTED + +}; + +#endif + + + + + + + diff --git a/noncore/multimedia/powerchord/config.in b/noncore/multimedia/powerchord/config.in new file mode 100644 index 0000000..c41844c --- a/dev/null +++ b/noncore/multimedia/powerchord/config.in @@ -0,0 +1,7 @@ + config POWERCHORD + boolean "opie-powerchord (guitar chord generator and tuning)" + default "n" + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && LIBOPIE2CORE + comment "opie-powerchord needs a libqpe, libopie and libopie2core" + depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE && LIBOPIE2CORE) + diff --git a/noncore/multimedia/powerchord/fretboard.cpp b/noncore/multimedia/powerchord/fretboard.cpp new file mode 100644 index 0000000..0687d00 --- a/dev/null +++ b/noncore/multimedia/powerchord/fretboard.cpp @@ -0,0 +1,234 @@ +// +// FretBoard class to display interface for chord finder application +// + +// Copyright (c) 2001 Camilo Mesias +// camilo@mesias.co.uk +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +//#include +//#include +//#include +#include +#include +#include +#include "fretboard.h" +#include + +void FretBoard::refresh(){ + ce.calculate(); + + emit nameChanged(QString(ce.label())); + + for (int i=0;i<6;i++){ + Finger(i, ce.finger(i)); + // yuk + switch (i) { + case 0: + emit s1nameChanged(QString(ce.name(i))); + break; + case 1: + emit s2nameChanged(QString(ce.name(i))); + break; + case 2: + emit s3nameChanged(QString(ce.name(i))); + break; + case 3: + emit s4nameChanged(QString(ce.name(i))); + break; + case 4: + emit s5nameChanged(QString(ce.name(i))); + break; + case 5: + emit s6nameChanged(QString(ce.name(i))); + break; + } + } + + update(); +} + +FretBoard::FretBoard(QWidget *parent, const char *name ) + : QWidget( parent, name ), ce() +{ + + ce.base(9); + ce.chord(0); + ce.fret(0); + ce.span(1); + ce.vary(7); + ce.tune(0); + refresh(); + + // setPalette( QPalette( QColor( 250, 250, 200) ) ); + + stringtop_pix = Resource::loadPixmap( "powerchord/stringtop_s"); + string_pix = Resource::loadPixmap( "powerchord/string_s"); + finger_pix = Resource::loadPixmap( "powerchord/justfing_s"); + mute_pix = Resource::loadPixmap( "powerchord/muted_s"); + + // box(FL_NO_BOX); + + // finger[0] = OPEN; + // finger[1] = OPEN; + // finger[2] = OPEN; + // finger[3] = OPEN; + // finger[4] = OPEN; + // finger[5] = OPEN; + + initial_fret = 0; + + // label(FL_NORMAL_LABEL, "Chord"); +} + +// int FretBoard::Finger(int f){ +// if (f < 0 || f > 5){ +// fprintf(stderr, "Error - finger value was %d\n", f); +// return 0; +// } +// return finger[f]; +// } + +void FretBoard::Finger(int f, int position){ + if (f < 0 || f > 5){ + fprintf(stderr, "Error - finger2 value was %d\n", f); + return; + } + + finger[f] = position; +} + +// void FretBoard::draw(void) { +// draw_box(); +// draw_label(); +// } + +// void FretBoard::draw_label(void) { +// align(FL_ALIGN_CENTER | FL_ALIGN_TOP | FL_ALIGN_WRAP); + +// this->Fl_Widget::draw_label(); +// } + + +//void FretBoard::draw_box(void) { + +void FretBoard::paintEvent(QPaintEvent *){ + + // fl_color(FL_WHITE); + + // Fl_Widget::draw_box(); + + // fl_color(FL_BLACK); + + QPainter p( this ); + + p.setBrush(black); + p.translate(0, 0); + + // draw each string + for (int f=0; f<=5; f++){ + // draw a string starting from the highest visible fret + for (int pp=0; pp<=6; pp++){ + int this_fret = initial_fret + pp; + int cx = /* x() + */ 28*f; + int cy = /* y() + */ pp*30; + + // fl_color(FL_WHITE); +// fl_rectf(cx, cy, 24, 24); + // p.setBrush(white); + // p.setPen(NoPen); + + // p.drawRect( QRect(cx, cy, 24, 24) ); +// fl_color(FL_BLACK); + // p.setBrush(black); + + // p.setPen(black); + + // draw the string unless at top + if (this_fret!=0){ + // fl_line(cx+12, cy, cx+12, cy+23); + // p.drawLine(cx+12, cy, cx+12, cy+23); + } + + // draw mutes if at top + if (pp == 0 && + finger[f] == MUTED){ + p.drawPixmap(cx,cy,mute_pix); + // fl_line(cx+4, cy+19, cx+19, cy+4); + // p.drawLine(cx+4, cy+19, cx+19, cy+4); + // fl_line(cx+5, cy+19, cx+20, cy+4); + // p.drawLine(cx+5, cy+19, cx+20, cy+4); + // fl_line(cx+4, cy+4, cx+19, cy+19); + // p.drawLine(cx+4, cy+4, cx+19, cy+19); + // fl_line(cx+5, cy+4, cx+20, cy+19); + // p.drawLine(cx+5, cy+4, cx+20, cy+19); + } + + if (this_fret==0){ + // above, blank + }else if(this_fret==1){ + // top + p.drawPixmap(cx,cy,stringtop_pix); + }else{ + // normal + p.drawPixmap(cx,cy,string_pix); + } + + // frets at bottom + // thick line if at top + // int x0 = (f==0)?(cx+12):cx; + // int x1 = (f==5)?(cx+12):(cx+23); + // for (int offset=23; offset>((this_fret==0)?20:22); offset--){ + // fl_line(x0, cy+offset, x1, cy+offset); + // p.drawLine(x0, cy+offset, x1, cy+offset); + // } + + // finger if at that position + if ((initial_fret==0 && pp == finger[f]) || + (initial_fret!=0 && pp == finger[f]-8)){ + p.drawPixmap(cx,cy,finger_pix); + +// fl_color(FL_WHITE); +// p.setBrush(white); +// p.setPen(NoPen); + +// fl_rectf(cx+4, cy+4, 16, 16); + // p.drawRect( QRect(cx+4, cy+4, 16, 16)); +// fl_color(FL_BLACK); + //p.setPen(black); +// fl_line(cx+4, cy+11, cx+7, cy+16); + //p.drawLine(cx+4, cy+11, cx+7, cy+16); +// fl_line(cx+7, cy+16, cx+12, cy+19); + //p.drawLine(cx+7, cy+16, cx+12, cy+19); +// fl_line(cx+12, cy+19, cx+16, cy+16); + //p.drawLine(cx+12, cy+19, cx+16, cy+16); +// fl_line(cx+16, cy+16, cx+19, cy+12); + //p.drawLine(cx+16, cy+16, cx+19, cy+12); +// fl_line(cx+19, cy+12, cx+16, cy+7); + //p.drawLine(cx+19, cy+12, cx+16, cy+7); +// fl_line(cx+16, cy+7, cx+12, cy+4); + //p.drawLine(cx+16, cy+7, cx+12, cy+4); +// fl_line(cx+11, cy+4, cx+7, cy+7); + //p.drawLine(cx+11, cy+4, cx+7, cy+7); +// fl_line(cx+7, cy+7, cx+4, cy+11); + //p.drawLine(cx+7, cy+7, cx+4, cy+11); + } + } + } + p.end(); +} + + diff --git a/noncore/multimedia/powerchord/fretboard.h b/noncore/multimedia/powerchord/fretboard.h new file mode 100644 index 0000000..d316df3 --- a/dev/null +++ b/noncore/multimedia/powerchord/fretboard.h @@ -0,0 +1,101 @@ +// +// FretBoard class to display interface for chord finder application +// + +// Copyright (c) 2001 Camilo Mesias +// camilo@mesias.co.uk +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __FRETBOARD_H +#define __FRETBOARD_H + +//#include +//#include + +#include +#include +#include + +#include "chordengine.h" + +class FretBoard : public QWidget { + + Q_OBJECT + + private: + + // refresh display based on chord engine + void refresh(); + + // image stuff + QPixmap stringtop_pix; + QPixmap string_pix; + QPixmap finger_pix; + QPixmap mute_pix; + + //saved state of the fretboard + + int initial_fret; + int finger[6]; + + protected: + // void draw_box(); + // void draw_label(); + void paintEvent(QPaintEvent *); + + public: + // encapsulated chord engine class + ChordEngine ce; + + static const int MUTED=7; + static const int OPEN=0; + + // void draw(); + FretBoard(QWidget *parent=0, const char *name=0); + + // not used yet + // int Finger(int finger); + // int Fret(){return initial_fret;}; + + // slots + public slots: + void Finger(int finger, int position); + + void Fret(int position){ + initial_fret = position; + ce.fret(position); + refresh(); + }; + void Base(int b){ce.base(b);refresh();}; + void Chord(int b){ce.chord(b);refresh();}; + void Span(int b){ce.span(b);refresh();}; + void Vary(int b){ce.vary(b);refresh();}; + void Tune(int b){ce.tune(b);refresh();}; + + signals: + void nameChanged(const QString &); + void s1nameChanged(const QString &); + void s2nameChanged(const QString &); + void s3nameChanged(const QString &); + void s4nameChanged(const QString &); + void s5nameChanged(const QString &); + void s6nameChanged(const QString &); + +}; + +#endif + + diff --git a/noncore/multimedia/powerchord/gs.cpp b/noncore/multimedia/powerchord/gs.cpp new file mode 100644 index 0000000..a3e85c9 --- a/dev/null +++ b/noncore/multimedia/powerchord/gs.cpp @@ -0,0 +1,460 @@ + +//#include +//#include +//#include +#include +//#include +#include "gs.h" + +#include +#include +#include +#include + +#include +#include + +#include + +//#include +#include + + +gs::gs() +{ + + finger[0] = OPEN; + finger[1] = OPEN; + finger[2] = OPEN; + finger[3] = OPEN; + finger[4] = OPEN; + finger[5] = OPEN; + + tuning[0] = 0; + tuning[1] = 0; + tuning[2] = 0; + tuning[3] = 0; + tuning[4] = 0; + tuning[5] = 0; + + initial_fret = 0; + + audio_fd = -1; + + pb_rate0 = 0; + pb_rate1 = 0; + pb_rate2 = 0; + pb_rate3 = 0; + pb_rate4 = 0; + pb_rate5 = 0; + pb_rate6 = 0; + + pb_oct0 = 0; + pb_oct1 = 0; + pb_oct2 = 0; + pb_oct3 = 0; + pb_oct4 = 0; + pb_oct5 = 0; + pb_oct6 = 0; + + // initialise reverb buffer + reverb = (signed short *)malloc(1024 * sizeof(signed short)); + + for (reverb_ptr=0;reverb_ptr<1024;reverb_ptr++){ + reverb[reverb_ptr] = 0; + } + reverb_ptr = 0; + reverb_max = 1024; + + // load sampled 'E' string + int samplen = 25000; + + signed short *dsp_buf = (signed short *)malloc(samplen * sizeof(signed short)); + signed short *dsp_buf_ptr = dsp_buf; + + int raw_fd; + raw_fd = open(ACGUITAR_PATH_S, O_RDONLY); + + if (raw_fd < 0){ + fprintf(stderr, "Failed to open raw file (%s)\n", strerror(errno)); + exit(-1); + } + + int totread = 0; + int i; + + while (totread < samplen*2){ + int want = samplen*2 - totread; + + int numread = read(raw_fd, dsp_buf_ptr, want); + fprintf(stderr, "read %d bytes\n", numread); + totread += numread; + dsp_buf_ptr += numread/2; + + if (numread == 0){ + fprintf(stderr, "failed to read bytes\n"); + exit(-1); + } + } + + close(raw_fd); + + // scale down a bit for mixing + for (i=0;i 5){ + fprintf(stderr, "Error - finger2 value was %d\n", f); + return; + } + + finger[f] = position; +} + +void gs::Tuning(int t[6]){ + for (int i=0;i<6;i++){ + tuning[i] = t[i]; + } +} + +// length in ps (seconds x 10^-9) of the period of a note. +// we use these as ratios in a breshenham-like algorithm to +// scale a deep note to a higher pitch +// They are derived from f(A) = 440Hz and multiply each successive +// semitone by the 12th root of 2 (such that after 12 multiplications for +// 12 semitones you have a note exactly 2x the frequency of the initial one, +// - an octave higher in other words.) + +int gs::note_periods[12] = { +90703, +85612, +80802, +76272, +71991, +67950, +64137, +60537, +57139, +53932, +50905, +48048 +}; + +int gs::octave_step[6] = { + 1, + 2, + 4, + 8, + 16, + 32 +}; + +int gs::Play(){ + int format; + int channels; + int speed; + + frames = 0; + + if (audio_fd == -1){ + if ( (audio_fd = open("/dev/dsp", O_WRONLY, 0) ) == -1){ + audio_fd = -1; + return 1; + } + + format = AFMT_S16_NE; + + if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format) == -1){ + fprintf(stderr, "Error SNDCTL DSP SETFMT, %s\n", strerror(errno)); + exit(0); + } + + channels = 1; + + if (ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &channels) == -1){ + fprintf(stderr, "Error SNDCTL DSP CHANNELS, %s\n", strerror(errno)); + exit(0); + } + + speed = 11025; + + if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &speed) == -1){ + fprintf(stderr, "Error SNDCTL DSP SPEED, %s\n", strerror(errno)); + exit(0); + } + + // buffering q's + // audio_buf_info info; + // if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) == -1){ + // fprintf(stderr, "Error SNDCTL DSP GETOSPACE, %s\n", strerror(errno)); + // exit(0); + // } + // fprintf(stderr, "fragments %d\nfragstotal %d\nfragsize %d\nbytes %d\n", info.fragments, info.fragstotal, info.fragsize, info.bytes); + + + +// audio math. +// A4 = 440Hz +// +1 octave = 2x freq +// -1 octave = /2 freq. +// +1 semitone = *= 12 root 2; +// ie. * 1.059463094 + +// tones, approx Hz, samples at 11025 +// A4 440 25 +// A#4 466 24 +// B4 494 22 +// C4 523 21 +// C#4 554 20 +// D4 587 19 +// D#4 622 18 +// E4 659 17 +// F4 698 16 +// F#4 740 15 +// G4 784 14 +// G#4 831 13 + + + } + else{ + fprintf(stderr, "Already playing\n"); + } + + return 0; +} + +void gs::note_start(int chan, int note, int octave) +{ + switch (chan){ + + case 0: + pb_rate0 = note_periods[note]; + pb_oct0 = octave_step[octave]; + pb_ratio0 = 0; + pb_rsc0 = 0; + break; + case 1: + pb_rate1 = note_periods[note]; + pb_oct1 = octave_step[octave]; + pb_ratio1 = 0; + pb_rsc1 = 0; + break; + case 2: + pb_rate2 = note_periods[note]; + pb_oct2 = octave_step[octave]; + pb_ratio2 = 0; + pb_rsc2 = 0; + break; + case 3: + pb_rate3 = note_periods[note]; + pb_oct3 = octave_step[octave]; + pb_ratio3 = 0; + pb_rsc3 = 0; + break; + case 4: + pb_rate4 = note_periods[note]; + pb_oct4 = octave_step[octave]; + pb_ratio4 = 0; + pb_rsc4 = 0; + break; + case 5: + pb_rate5 = note_periods[note]; + pb_oct5 = octave_step[octave]; + pb_ratio5 = 0; + pb_rsc5 = 0; + break; + case 6: + pb_rate6 = note_periods[note]; + pb_oct6 = octave_step[octave]; + pb_ratio6 = 0; + pb_rsc6 = 0; + break; + default: + fprintf(stderr, "Bad channel\n"); + exit(-1); + } + + +} + +void gs::write_buffer(){ + int num_read; + num_read = write(audio_fd, (void *)audio_buf, BUFSIZE*2); + // fprintf(stderr, "Wrote %d bytes\n", num_read); +} + +void gs::fill_buffer() +{ + frames ++; + + int i; + + for (i=0;i= pb_rate0){ + pb_rsc0 += pb_oct0; + pb_ratio0 -= pb_rate0; + + } + if (pb_rsc0 >= tonebank_length0) pb_rate0 = 0; + } + + if (pb_rate1){ + audio_buf[i] += tonebank1[pb_rsc1]; + pb_rsc1 += pb_oct1; + pb_ratio1 += 90703; + pb_ratio1 -= pb_rate1; + if (pb_ratio1 >= pb_rate1){ + pb_rsc1 += pb_oct1; + pb_ratio1 -= pb_rate1; + + } + if (pb_rsc1 >= tonebank_length1) pb_rate1 = 0; + } + + if (pb_rate2){ + audio_buf[i] += tonebank2[pb_rsc2]; + pb_rsc2 += pb_oct2; + pb_ratio2 += 90703; + pb_ratio2 -= pb_rate2; + if (pb_ratio2 >= pb_rate2){ + pb_rsc2 += pb_oct2; + pb_ratio2 -= pb_rate2; + + } + if (pb_rsc2 >= tonebank_length2) pb_rate2 = 0; + } + + if (pb_rate3){ + audio_buf[i] += tonebank3[pb_rsc3]; + pb_rsc3 += pb_oct3; + pb_ratio3 += 90703; + pb_ratio3 -= pb_rate3; + if (pb_ratio3 >= pb_rate3){ + pb_rsc3 += pb_oct3; + pb_ratio3 -= pb_rate3; + + } + if (pb_rsc3 >= tonebank_length3) pb_rate3 = 0; + } + + if (pb_rate4){ + audio_buf[i] += tonebank4[pb_rsc4]; + pb_rsc4 += pb_oct4; + pb_ratio4 += 90703; + pb_ratio4 -= pb_rate4; + if (pb_ratio4 >= pb_rate4){ + pb_rsc4 += pb_oct4; + pb_ratio4 -= pb_rate4; + + } + if (pb_rsc4 >= tonebank_length4) pb_rate4 = 0; + } + + if (pb_rate5){ + audio_buf[i] += tonebank5[pb_rsc5]; + pb_rsc5 += pb_oct5; + pb_ratio5 += 90703; + pb_ratio5 -= pb_rate5; + if (pb_ratio5 >= pb_rate5){ + pb_rsc5 += pb_oct5; + pb_ratio5 -= pb_rate5; + + } + if (pb_rsc5 >= tonebank_length5) pb_rate5 = 0; + } + + if (pb_rate6){ + audio_buf[i] += tonebank6[pb_rsc6]; + pb_rsc6 += pb_oct6; + pb_ratio6 += 90703; + pb_ratio6 -= pb_rate6; + if (pb_ratio6 >= pb_rate6){ + pb_rsc6 += pb_oct6; + pb_ratio6 -= pb_rate6; + + } + if (pb_rsc6 >= tonebank_length6) pb_rate6 = 0; + } + + // do reverb + signed short rtmp = reverb[reverb_ptr]; + reverb[reverb_ptr] /= 2; + reverb[reverb_ptr] += audio_buf[i]/4; + audio_buf[i] += rtmp; + reverb_ptr++; + if (reverb_ptr >= reverb_max) reverb_ptr = 0; + } +} + + +void gs::Stop(){ + if (audio_fd == -1){ + fprintf(stderr, "Already stopped\n"); + } + else{ + //ioctl(audio_fd, SNDCTL_DSP_RESET, 0); + + close(audio_fd); + audio_fd = -1; + } + +} + +gs::~gs() +{} diff --git a/noncore/multimedia/powerchord/gs.h b/noncore/multimedia/powerchord/gs.h new file mode 100644 index 0000000..3e4c04d --- a/dev/null +++ b/noncore/multimedia/powerchord/gs.h @@ -0,0 +1,124 @@ + +#ifndef __GS_H +#define __GS_H + +#include +// sound includes +#include + +#define BUFSIZE 256 +#define NUMCHANS 7 +#define ACGUITAR_PATH_S "/usr/local/projects/opie-head/noncore/multimedia/powerchord/acguitar.raw" + +class gs : public QObject { + + Q_OBJECT + + public: + gs(); + ~gs(); + + private: + + int initial_fret; + int finger[6]; + int tuning[6]; + + signed short *reverb; + int reverb_ptr; + int reverb_max; + + int audio_fd; + signed short audio_buf[BUFSIZE]; + static int note_periods[12]; + static int octave_step[6]; + int frames; + + + // 7 channel synth + signed short *tonebank0; // source of waveform + signed short *tonebank1; + signed short *tonebank2; + signed short *tonebank3; + signed short *tonebank4; + signed short *tonebank5; + signed short *tonebank6; + int tonebank_length0; + int tonebank_length1; + int tonebank_length2; + int tonebank_length3; + int tonebank_length4; + int tonebank_length5; + int tonebank_length6; + int pb_rate0; // playback rate or 0 + int pb_rate1; + int pb_rate2; + int pb_rate3; + int pb_rate4; + int pb_rate5; + int pb_rate6; + int pb_ratio0; // accumulator for ratio + int pb_ratio1; + int pb_ratio2; + int pb_ratio3; + int pb_ratio4; + int pb_ratio5; + int pb_ratio6; + int pb_rsc0; // pointer to current position + int pb_rsc1; + int pb_rsc2; + int pb_rsc3; + int pb_rsc4; + int pb_rsc5; + int pb_rsc6; + int pb_oct0; // octave + int pb_oct1; + int pb_oct2; + int pb_oct3; + int pb_oct4; + int pb_oct5; + int pb_oct6; + + void set_tonebank(int bank, signed short *buffer, int length); + protected: + + public: + static const int MUTED=7; + static const int OPEN=0; + + // accessors + int Frames(){return frames;}; + int Finger(int finger); + int Fret(){return initial_fret;}; + int Playing(){ + if (pb_rate0 == 0 && + pb_rate1 == 0 && + pb_rate2 == 0 && + pb_rate3 == 0 && + pb_rate4 == 0 && + pb_rate5 == 0 && + pb_rate6 == 0) return 0; + return 1; + }; + + public : + // mutators + void Reverb(int size){reverb_max = 64 * size;}; + void Finger(int finger, int position); + void Fret(int position){initial_fret = position;}; + void Tuning(int t[6]); + void note_start(int chan, int note, int octave); + + // methods + int Play(); + void fill_buffer(); + void write_buffer(); + void Stop(); +}; + +#endif + + + + + diff --git a/noncore/multimedia/powerchord/gt.cpp b/noncore/multimedia/powerchord/gt.cpp new file mode 100644 index 0000000..0db5f0f --- a/dev/null +++ b/noncore/multimedia/powerchord/gt.cpp @@ -0,0 +1,39 @@ + +//#include +//#include +//#include +#include +//#include +#include "gt.h" + +#include +#include +#include +#include + +#include +#include + +#include + +gt::gt() +{ + + audio_fd = -1; + +} + +void gt::Stop(){ +} + +void gt::Listen(){ +} + +void gt::read_buffer(){ +} + +void gt::process_buffer(){ +} + +gt::~gt() +{} diff --git a/noncore/multimedia/powerchord/gt.h b/noncore/multimedia/powerchord/gt.h new file mode 100644 index 0000000..53c9f08 --- a/dev/null +++ b/noncore/multimedia/powerchord/gt.h @@ -0,0 +1,54 @@ + +#ifndef __GT_H +#define __GT_H + +#include +// sound includes +#include + +#define BUFSIZE 256 +#define NUMCHANS 7 + +class gt : public QObject { + + Q_OBJECT + + public: + gt(); + ~gt(); + + private: + + int audio_fd; + signed short audio_buf[BUFSIZE]; + + int note; + int tune; + + short min; + short max; + int phase; + + protected: + + public: + + // accessors + int Tuning(){return tune;}; + int Note(){return note;}; + int Listening(){return (audio_fd == -1);}; + + public slots : + // methods + void Listen(); + void process_buffer(); + void read_buffer(); + void Stop(); +}; + +#endif + + + + + diff --git a/noncore/multimedia/powerchord/main.cpp b/noncore/multimedia/powerchord/main.cpp new file mode 100644 index 0000000..7fca87c --- a/dev/null +++ b/noncore/multimedia/powerchord/main.cpp @@ -0,0 +1,12 @@ +#include "powerchord.h" +#include + +int main( int argc, char ** argv ) +{ + QPEApplication a( argc, argv ); + + PowerchordBase p; + a.showMainWidget( &p ); + + return a.exec(); +} diff --git a/noncore/multimedia/powerchord/opie-powerchord.control b/noncore/multimedia/powerchord/opie-powerchord.control new file mode 100644 index 0000000..7f45999 --- a/dev/null +++ b/noncore/multimedia/powerchord/opie-powerchord.control @@ -0,0 +1,10 @@ +Files: bin/powerchord apps/Applications/powerchord.desktop pics/powerchord sounds/powerchord +Priority: optional +Section: qpe/applications +Maintainer: Camilo Mesias +Architecture: arm +Version: 0.0.7 +Depends: qpe-base ($QPE_VERSION) +Description: Guitar Chord generator application +Allows naming of chords using base note and key. Fretboard diagrams are +produced illustrating ways to play the chord. diff --git a/noncore/multimedia/powerchord/powerchord.cpp b/noncore/multimedia/powerchord/powerchord.cpp new file mode 100644 index 0000000..79a26ea --- a/dev/null +++ b/noncore/multimedia/powerchord/powerchord.cpp @@ -0,0 +1,28 @@ +#include "powerchord.h" +#include + +/* + * Constructs a Example which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +Powerchord::Powerchord( QWidget* parent, const char* name, WFlags fl ) + : PowerchordBase( parent, name, fl ) +{ +// connect(quit, SIGNAL(clicked), this, SLOT(goodBye())); +} + +/* + * Destroys the object and frees any allocated resources + */ +Powerchord::~Powerchord() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * A simple slot... not very interesting. + */ +void Powerchord::goodBye() +{ + close(); +} diff --git a/noncore/multimedia/powerchord/powerchord.h b/noncore/multimedia/powerchord/powerchord.h new file mode 100644 index 0000000..0793fd2 --- a/dev/null +++ b/noncore/multimedia/powerchord/powerchord.h @@ -0,0 +1,17 @@ +#ifndef POWERCHORD_H +#define POWERCHORD_H +#include "powerchordbase.h" + +class Powerchord : public PowerchordBase +{ + Q_OBJECT + +public: + Powerchord( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~Powerchord(); + +private slots: + void goodBye(); +}; + +#endif // POWERCHORD_H diff --git a/noncore/multimedia/powerchord/powerchord.ui b/noncore/multimedia/powerchord/powerchord.ui new file mode 100644 index 0000000..d70001a --- a/dev/null +++ b/noncore/multimedia/powerchord/powerchord.ui @@ -0,0 +1,55 @@ + +Powerchord + + QWidget + + name + Form1 + + + geometry + + 0 + 0 + 196 + 245 + + + + caption + Form1 + + + + margin + 11 + + + spacing + 6 + + + QLabel + + name + TextLabel1 + + + text + <p>This is just an <i>example</i>. It doesn't do anything interesting at all. + + + + QPushButton + + name + quit + + + text + Quit + + + + + diff --git a/noncore/multimedia/powerchord/powerchordbase.cpp b/noncore/multimedia/powerchord/powerchordbase.cpp new file mode 100644 index 0000000..0b97984 --- a/dev/null +++ b/noncore/multimedia/powerchord/powerchordbase.cpp @@ -0,0 +1,592 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'powerchordbase.ui' +** +** Created: Sun Jan 13 23:05:11 2002 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "powerchordbase.h" + +#include "fretboard.h" +#include "vumeter.h" +#include "gs.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* + * Constructs a PowerchordBase which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +PowerchordBase::PowerchordBase( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + simulation_timer = 0; + audio_timer = 0; + + // setPalette( QPalette( QColor( 232, 227, 215) ) ); + + // QPixmap image0(QString("/opt/Qtopia/pics/powerchord/image0")); + QPixmap image1 = Resource::loadPixmap( "powerchord/image1"); + QPixmap image2 = Resource::loadPixmap( "powerchord/image2"); + QPixmap image3 = Resource::loadPixmap( "powerchord/image3"); + QPixmap image4 = Resource::loadPixmap( "powerchord/image4"); + QPixmap image5 = Resource::loadPixmap( "powerchord/image5"); + image6 = Resource::loadPixmap( "powerchord/image6"); + image_open = Resource::loadPixmap( "powerchord/image_open"); + + // image0.setMask(image0.createHeuristicMask()); + image1.setMask(image1.createHeuristicMask()); + // image2.setMask(image2.createHeuristicMask()); + // image3.setMask(image3.createHeuristicMask()); + // image4.setMask(image4.createHeuristicMask()); + // image5.setMask(image5.createHeuristicMask()); + // image6->setMask(image6->createHeuristicMask()); + // image_open->setMask(image_open->createHeuristicMask()); + + if ( !name ) + setName( "PowerchordBase" ); + resize( 240, 284 ); + setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, sizePolicy().hasHeightForWidth() ) ); + setMinimumSize( QSize( 240, 284 ) ); + setMaximumSize( QSize( 240, 284 ) ); + setCaption( tr( "Powerchord" ) ); + + tabs = new QTabWidget( this, "tabs" ); + tabs->setEnabled( TRUE ); + tabs->setGeometry( QRect( 0, 0, 240, 286 ) ); + tabs->setTabPosition( QTabWidget::Bottom ); + + tab = new QWidget( tabs, "tab" ); + + chordkey = new QComboBox( FALSE, tab, "chordkey" ); + chordkey->insertItem( tr( "maj" ) ); + chordkey->insertItem( tr( "min" ) ); + chordkey->insertItem( tr( "7th" ) ); + chordkey->insertItem( tr( "m7" ) ); + chordkey->insertItem( tr( "maj7" ) ); + chordkey->insertItem( tr( "6th" ) ); + chordkey->insertItem( tr( "m6th" ) ); + chordkey->insertItem( tr( "aug" ) ); + chordkey->insertItem( tr( "dim" ) ); + chordkey->insertItem( tr( "sus4" ) ); + chordkey->insertItem( tr( "7sus4" ) ); + chordkey->insertItem( tr( "9th" ) ); + chordkey->insertItem( tr( "add9" ) ); + chordkey->insertItem( tr( "m9th" ) ); + chordkey->insertItem( tr( "maj9" ) ); + chordkey->insertItem( tr( "sus2" ) ); + chordkey->insertItem( tr( "7sus2" ) ); + chordkey->insertItem( tr( "11th" ) ); + chordkey->insertItem( tr( "m11th" ) ); + chordkey->insertItem( tr( "13th" ) ); + chordkey->insertItem( tr( "m13th" ) ); + chordkey->insertItem( tr( "maj13" ) ); + chordkey->insertItem( tr( "6/9" ) ); + chordkey->insertItem( tr( "flat5" ) ); + chordkey->insertItem( tr( "7#9" ) ); + chordkey->insertItem( tr( QString::fromUtf8( "ø7" ) ) ); + chordkey->insertItem( tr( "5" ) ); + chordkey->setGeometry( QRect( 40, 0, 51, 21 ) ); + + chordfret = new QComboBox( FALSE, tab, "chordfret" ); + chordfret->insertItem( tr( "open" ) ); + chordfret->insertItem( tr( "1st" ) ); + chordfret->insertItem( tr( "2nd" ) ); + chordfret->insertItem( tr( "3rd" ) ); + chordfret->insertItem( tr( "4th" ) ); + chordfret->insertItem( tr( "5th" ) ); + chordfret->insertItem( tr( "6th" ) ); + chordfret->insertItem( tr( "7th" ) ); + chordfret->insertItem( tr( "8th" ) ); + chordfret->insertItem( tr( "9th" ) ); + chordfret->insertItem( tr( "10th" ) ); + chordfret->insertItem( tr( "11th" ) ); + chordfret->insertItem( tr( "12th" ) ); + chordfret->insertItem( tr( "13th" ) ); + chordfret->insertItem( tr( "14th" ) ); + chordfret->insertItem( tr( "15th" ) ); + chordfret->insertItem( tr( "16th" ) ); + chordfret->setGeometry( QRect( 90, 0, 55, 21 ) ); //cxm less 5 width + + chordnote = new QComboBox( FALSE, tab, "chordnote" ); + chordnote->insertItem( tr( "C" ) ); + chordnote->insertItem( tr( "C#" ) ); + chordnote->insertItem( tr( "D" ) ); + chordnote->insertItem( tr( "Eb" ) ); + chordnote->insertItem( tr( "E" ) ); + chordnote->insertItem( tr( "F" ) ); + chordnote->insertItem( tr( "F#" ) ); + chordnote->insertItem( tr( "G" ) ); + chordnote->insertItem( tr( "G#" ) ); + chordnote->insertItem( tr( "A" ) ); + chordnote->insertItem( tr( "Bb" ) ); + chordnote->insertItem( tr( "B" ) ); + chordnote->setGeometry( QRect( 0, 0, 40, 21 ) ); + chordnote->setCurrentItem( 9 ); + + QWidget* privateLayoutWidget = new QWidget( tab, "Layout1" ); + privateLayoutWidget->setGeometry( QRect( 5, 232, 160, 20 ) ); + Layout1 = new QHBoxLayout( privateLayoutWidget ); + Layout1->setSpacing( 6 ); + Layout1->setMargin( 0 ); + + s1_1 = new QLabel( privateLayoutWidget, "s1_1" ); + s1_1->setText( tr( "E" ) ); + s1_1->setAlignment( int( QLabel::AlignCenter ) ); + Layout1->addWidget( s1_1 ); + + s1_2 = new QLabel( privateLayoutWidget, "s1_2" ); + s1_2->setText( tr( "A" ) ); + s1_2->setAlignment( int( QLabel::AlignCenter ) ); + Layout1->addWidget( s1_2 ); + + s1_3 = new QLabel( privateLayoutWidget, "s1_3" ); + s1_3->setText( tr( "E" ) ); + s1_3->setAlignment( int( QLabel::AlignCenter ) ); + Layout1->addWidget( s1_3 ); + + s1_4 = new QLabel( privateLayoutWidget, "s1_4" ); + s1_4->setText( tr( "A" ) ); + s1_4->setAlignment( int( QLabel::AlignCenter ) ); + Layout1->addWidget( s1_4 ); + + s1_5 = new QLabel( privateLayoutWidget, "s1_5" ); + s1_5->setText( tr( "C#" ) ); + s1_5->setAlignment( int( QLabel::AlignCenter ) ); + Layout1->addWidget( s1_5 ); + + s1_6 = new QLabel( privateLayoutWidget, "s1_6" ); + s1_6->setText( tr( "E" ) ); + s1_6->setAlignment( int( QLabel::AlignCenter ) ); + Layout1->addWidget( s1_6 ); + + // sound_label = new QLabel( tab, "sound_label" ); + // sound_label->setGeometry( QRect( 185, 160, 32, 17 ) ); + // sound_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sound_label->sizePolicy().hasHeightForWidth() ) ); + // sound_label->setPixmap( image0 ); + // sound_label->pixmap()->setMask(*image0.mask()); + // sound_label->setScaledContents( TRUE ); + // sound_label->setBackgroundMode( QWidget::PaletteButton ); + // sound_label->setBackgroundColor(this->backgroundColor()); + // sound_label->setPalette( QPalette( QColor( 232, 227, 215) ) ); + + + Frame6 = new QFrame( tab, "Frame6" ); + Frame6->setGeometry( QRect( 170, 145, 66, 10 ) ); + Frame6->setFrameShape( QFrame::HLine ); + Frame6->setFrameShadow( QFrame::Raised ); + + chordshow_label = new QLabel( tab, "chordshow_label" ); + chordshow_label->setGeometry( QRect( 185, 60, 32, 17 ) ); + // chordshow_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, chordshow_label->sizePolicy().hasHeightForWidth() ) ); + chordshow_label->setFrameShape( QLabel::NoFrame ); + chordshow_label->setPixmap( image1 ); + chordshow_label->setScaledContents( TRUE ); + // chordshow_label->setBackgroundMode( QWidget::PaletteButton ); + + transport_rec = new QPushButton( tab, "transport_rec" ); + transport_rec->setGeometry( QRect( 170, 80, 30, 30 ) ); + transport_rec->setText( tr( "" ) ); + transport_rec->setPixmap( image2 ); + + play_sound = new QPushButton( tab, "play_sound" ); + play_sound->setGeometry( QRect( 170, 180, 60, 55 ) ); + play_sound->setText( tr( "" ) ); + play_sound->setPixmap( image3 ); + + Frame6_2 = new QFrame( tab, "Frame6_2" ); + Frame6_2->setGeometry( QRect( 170, 45, 66, 10 ) ); + Frame6_2->setFrameShape( QFrame::HLine ); + Frame6_2->setFrameShadow( QFrame::Raised ); + + transport_play = new QPushButton( tab, "transport_play" ); + transport_play->setEnabled( FALSE ); + transport_play->setGeometry( QRect( 200, 80, 30, 30 ) ); + transport_play->setText( tr( "" ) ); + transport_play->setPixmap( image3 ); + + transport_rew = new QPushButton( tab, "transport_rew" ); + transport_rew->setEnabled( FALSE ); + transport_rew->setGeometry( QRect( 170, 110, 30, 30 ) ); + transport_rew->setText( tr( "" ) ); + transport_rew->setPixmap( image4 ); + + transport_fwd = new QPushButton( tab, "transport_fwd" ); + transport_fwd->setEnabled( FALSE ); + transport_fwd->setGeometry( QRect( 200, 110, 30, 30 ) ); + transport_fwd->setText( tr( "" ) ); + transport_fwd->setPixmap( image5 ); + + chordname = new QLabel( tab, "chordname" ); + chordname->setGeometry( QRect( 146, 0, 90, 20 ) ); //cxm moved l 5 + chordname->setText( tr( "A" ) ); + chordname->setAlignment( int( QLabel::AlignCenter ) ); + QToolTip::add( chordname, tr( "" ) ); + + synth = new gs(); + tuner = new gt(); + frets = new FretBoard( tab, "frets" ); + frets->setGeometry( QRect( 0, 20, 168, 210 ) ); + tabs->insertTab( tab, tr( "Guitar" ) ); + + tab_2 = new QWidget( tabs, "tab_2" ); + + optlab2 = new QLabel( tab_2, "optlab2" ); + optlab2->setGeometry( QRect( 9, 58, 120, 41 ) ); + optlab2->setText( tr( "Alternative tunings are possible" ) ); + optlab2->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); + + span = new QComboBox( FALSE, tab_2, "span" ); + span->insertItem( tr( "2" ) ); + span->insertItem( tr( "3" ) ); + span->insertItem( tr( "4" ) ); + span->insertItem( tr( "5" ) ); + span->insertItem( tr( "6" ) ); + span->setGeometry( QRect( 180, 20, 50, 21 ) ); + span->setCurrentItem( 1 ); + + TextLabel1 = new QLabel( tab_2, "TextLabel1" ); + TextLabel1->setGeometry( QRect( 3, 109, 226, 140 ) ); + TextLabel1->setText( tr( QString::fromUtf8( "©2002 Camilo Mesias\n" +"camilo@mesias.co.uk\n" +"Version 0.0.7 beta" ) ) ); + TextLabel1->setAlignment( int( QLabel::AlignBottom | QLabel::AlignLeft ) ); + + tuning = new QComboBox( FALSE, tab_2, "tuning" ); + tuning->insertItem( tr( "EADGBE" ) ); + tuning->insertItem( tr( "EBEG#BE" ) ); + tuning->insertItem( tr( "EAEAC#E" ) ); + tuning->insertItem( tr( "EADF#BE" ) ); + tuning->insertItem( tr( "EADGCF" ) ); + tuning->insertItem( tr( "DADGAD" ) ); + tuning->insertItem( tr( "DGCGCD" ) ); + tuning->insertItem( tr( "DADF#AD" ) ); + tuning->insertItem( tr( "DADGBE" ) ); + tuning->insertItem( tr( "DGDGBD" ) ); + tuning->insertItem( tr( "DADACD" ) ); + tuning->insertItem( tr( "CGCGAE" ) ); + tuning->insertItem( tr( "FADGBE" ) ); + tuning->insertItem( tr( "G minor" ) ); + tuning->setGeometry( QRect( 140, 70, 91, 21 ) ); + + optlab1 = new QLabel( tab_2, "optlab1" ); + optlab1->setGeometry( QRect( 8, 8, 160, 40 ) ); + optlab1->setText( tr( "Span: the greatest number of frets over which you want chords to be generated" ) ); + optlab1->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); + tabs->insertTab( tab_2, tr( "Options" ) ); + + Tuner = new QWidget( tabs, "Tuner" ); + + Frame4 = new QFrame( Tuner, "Frame4" ); + Frame4->setGeometry( QRect( 0, 0, 230, 126 ) ); + Frame4->setFrameShape( QFrame::Box ); + Frame4->setFrameShadow( QFrame::Raised ); + + vu = new VUMeter( Frame4, "vu" ); + vu->setGeometry( QRect( 5, 5, 220, 115 ) ); + + tuner_note = new QComboBox( FALSE, Tuner, "tuner_note" ); + tuner_note->insertItem( tr( "auto" ) ); + tuner_note->insertItem( tr( "E" ) ); + tuner_note->insertItem( tr( "D" ) ); + tuner_note->insertItem( tr( "G" ) ); + tuner_note->insertItem( tr( "A" ) ); + tuner_note->insertItem( tr( "B" ) ); + tuner_note->insertItem( tr( "C" ) ); + tuner_note->insertItem( tr( "F" ) ); + tuner_note->setGeometry( QRect( 5, 160, 90, 20 ) ); + + Frame8 = new QFrame( Tuner, "Frame8" ); + Frame8->setGeometry( QRect( -2, 188, 231, 10 ) ); + Frame8->setFrameShape( QFrame::HLine ); + Frame8->setFrameShadow( QFrame::Raised ); + + tuner_start = new QPushButton( Tuner, "tuner_start" ); + tuner_start->setGeometry( QRect( 100, 155, 91, 30 ) ); + tuner_start->setText( tr( "Start" ) ); + + tuner_lab1 = new QLabel( Tuner, "tuner_lab1" ); + tuner_lab1->setGeometry( QRect( 10, 130, 100, 21 ) ); + tuner_lab1->setText( tr( "Tuner operation" ) ); + + tuner_lab2 = new QLabel( Tuner, "tuner_lab2" ); + tuner_lab2->setGeometry( QRect( 10, 200, 100, 16 ) ); + tuner_lab2->setText( tr( "Pitch calibration" ) ); + + tuner_calib_note = new QComboBox( FALSE, Tuner, "tuner_calib_note" ); + tuner_calib_note->insertItem( tr( "A" ) ); + tuner_calib_note->insertItem( tr( "C" ) ); + tuner_calib_note->setGeometry( QRect( 5, 225, 90, 21 ) ); + + tuner_calib_freq = new QSpinBox( Tuner, "tuner_calib_freq" ); + tuner_calib_freq->setGeometry( QRect( 105, 225, 71, 21 ) ); + tuner_calib_freq->setSuffix( tr( "Hz" ) ); + tuner_calib_freq->setWrapping( TRUE ); + tuner_calib_freq->setMaxValue( 500 ); + tuner_calib_freq->setMinValue( 300 ); + tuner_calib_freq->setValue( 440 ); + + tuner_lab3 = new QLabel( Tuner, "tuner_lab3" ); + tuner_lab3->setGeometry( QRect( 185, 225, 40, 21 ) ); + tuner_lab3->setText( tr( "Pitch" ) ); + + tuner_pic1 = new QLabel( Tuner, "tuner_pic1" ); + tuner_pic1->setGeometry( QRect( 195, 155, 31, 31 ) ); + tuner_pic1->setFrameShape( QLabel::NoFrame ); + tuner_pic1->setPixmap( image6 ); + tuner_pic1->setScaledContents( TRUE ); + tabs->insertTab( Tuner, tr( "Tuner" ) ); + + tab_3 = new QWidget( tabs, "tab_3" ); + + chordlistlab1 = new QLabel( tab_3, "chordlistlab1" ); + chordlistlab1->setGeometry( QRect( 5, 5, 216, 16 ) ); + chordlistlab1->setText( tr( "Chord list" ) ); + + chordlist = new QListBox( tab_3, "chordlist" ); + chordlist->setGeometry( QRect( 5, 25, 220, 200 ) ); + + list_remove_btn = new QPushButton( tab_3, "list_remove_btn" ); + list_remove_btn->setGeometry( QRect( 150, 230, 71, 25 ) ); + list_remove_btn->setText( tr( "Remove" ) ); + tabs->insertTab( tab_3, tr( "Chords" ) ); + + // hope this does what it's supposed to!! + // setPalette( QPalette( QColor( 232, 227, 215) ) ); + + // signals and slots connections + + //cxm + connect( tuning, SIGNAL( activated(int) ), frets, SLOT( Tune(int) ) ); + connect( span, SIGNAL( activated(int) ), frets, SLOT( Span(int) ) ); + connect( transport_rec, SIGNAL( clicked() ), this, SLOT( transport_rec_cb() )); + connect( play_sound, SIGNAL( clicked() ), this, SLOT( play_chord_cb() )); + connect( tuner_start, SIGNAL( clicked() ), this, SLOT( tuner_start_cb() )); + connect( tuner_note, SIGNAL( textChanged(const QString&) ), vu, SLOT( AnnotL(const QString&) )); + connect( this, SIGNAL( frequency_change(int) ), vu, SLOT( Value(int) )); + + connect( chordnote, SIGNAL( activated(int) ), frets, SLOT( Base(int) ) ); + connect( chordkey, SIGNAL( activated(int) ), frets, SLOT( Chord(int) ) ); + connect( chordfret, SIGNAL( activated(int) ), frets, SLOT( Fret(int) ) ); + connect( list_remove_btn, SIGNAL( clicked() ), this, SLOT( list_remove_cb() ) ); + connect( frets, SIGNAL( s1nameChanged(const QString &) ), s1_1, SLOT( setText(const QString&) ) ); + connect( frets, SIGNAL( s2nameChanged(const QString &) ), s1_2, SLOT( setText(const QString&) ) ); + connect( frets, SIGNAL( s3nameChanged(const QString &) ), s1_3, SLOT( setText(const QString&) ) ); + connect( frets, SIGNAL( s4nameChanged(const QString &) ), s1_4, SLOT( setText(const QString&) ) ); + connect( frets, SIGNAL( s5nameChanged(const QString &) ), s1_5, SLOT( setText(const QString&) ) ); + connect( frets, SIGNAL( s6nameChanged(const QString &) ), s1_6, SLOT( setText(const QString&) ) ); + connect( frets, SIGNAL( nameChanged(const QString &) ), chordname, SLOT( setText(const QString&) ) ); +} + + +static int known=0; +#include +void PowerchordBase::transport_rec_cb(){ + chordlist->insertItem(chordname->text(),-1); + if (!known){ + QMessageBox::information(this, "Powerchord", "This chord has been saved\ninto the list of chords,\nfor later playback."); + known = 1; + } +} +void PowerchordBase::list_remove_cb(){ + if (chordlist->count() > 0){ + chordlist->removeItem(0); + } +} +void PowerchordBase::play_chord_cb(){ + // QMessageBox::information(this, "Coming soon!", "This button plays\nthe chord by synthesizing\nthe sound of the notes."); + + + if (audio_timer){ + audio_timer->stop(); + // set pixmap? + synth->Stop(); + delete(audio_timer); + audio_timer = 0; + }else{ + // get notes from chord engine + + int note; + int base; + int octave; + note = frets->ce.noteindex(0); + if (note >= 0){ + // fprintf(stderr, "Note was %d\n", note); + base = note % 12; + octave = note / 12; + synth->note_start(0, base, octave); + }else{ + // subtle bug here - replay second note if 1st one muted + note = frets->ce.noteindex(1); + base = note % 12; + octave = note / 12; + synth->note_start(1, base, octave); + + } + + // init synth + if (synth->Play()){ + // error + QMessageBox::information(this, "Powerchord", "Unable to open device for sound playback - check that no other application is using it."); + return; + } + synth->fill_buffer(); + + // start timer + audio_timer = new QTimer(); + connect(audio_timer, SIGNAL( timeout() ), this, SLOT( audio_cb() )); + // set pixmap on player? + audio_timer->start(19); // 19 msec (fudge factor!!) + } +} + + + +void PowerchordBase::audio_cb(){ + // play the next bit of audio until quiet + + // strum timing +#define INTERVAL 2 + + if ((synth->Frames() % INTERVAL) == 0){ + int string = synth->Frames() / INTERVAL; + if (string <= 5){ + int note; + int base; + int octave; + note = frets->ce.noteindex(string); + // check not muted... + if (note > 0){ + base = note % 12; + octave = note / 12; + synth->note_start(string, base, octave); + } + } + } + + if (synth->Playing()){ + synth->write_buffer(); + synth->fill_buffer(); + }else{ + audio_timer->stop(); + // set pixmap? + synth->Stop(); + delete(audio_timer); + audio_timer = 0; + } +} + +// the real tuner +// void PowerchordBase::tuner_start_cb(){ + +// if (tuner->Listening()){ +// simulation_timer->stop(); +// tuner->Stop(); +// tuner_pic1->setPixmap( *image6 ); + +// }else{ +// tuner_pic1->setPixmap( *image_open ); + +// if (!simulation_timer){ +// simulation_timer = new QTimer(); + + +// connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_cb() )); +// } + +// simulation_timer->start(50); +// tuner->Listen(); + +// } +// } + +void PowerchordBase::tuner_cb(){ + if (tuner->Listening()){ + tuner->read_buffer(); + tuner->process_buffer(); + + // update gui + // do something with the note: tuner->Note() + emit frequency_change(tuner->Tuning()); + + }else{ + simulation_timer->stop(); + tuner->Stop(); + tuner_pic1->setPixmap( image6 ); + } +} + + +void PowerchordBase::tuner_start_cb(){ + if (0 == QMessageBox::information(this, "Powerchord", "Using the microphone,\nthe note's frequency\nis analysed. This\nis a simulation.", "OK", "Cancel", 0, 1)){ + if (simulation_timer){ + simulation_timer->stop(); + }else{ + simulation_timer = new QTimer(); + connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_simulation_cb() )); + + } + simulation_x = -45; + simulation_v = 0; + simulation_iter = 0; + + tuner_pic1->setPixmap( image_open ); + simulation_timer->start(100); + } +} + +#include + +void PowerchordBase::tuner_simulation_cb(){ + if (simulation_x < -10 || simulation_x > 10){ + simulation_v = (simulation_v/2)-(simulation_x/5); + } + + simulation_x += simulation_v; + simulation_iter++; + + if (simulation_x > 50){ + simulation_x = 50; + } + + if (simulation_x < -50){ + simulation_x = -50; + } + + if (simulation_iter > 50){ + simulation_timer->stop(); + emit frequency_change(0); + tuner_pic1->setPixmap( image6 ); + }else{ + emit frequency_change(simulation_x); + } +} + +/* + * Destroys the object and frees any allocated resources + */ +PowerchordBase::~PowerchordBase() +{ + // no need to delete child widgets, Qt does it all for us +} + +void PowerchordBase::change_handler() +{ + qWarning( "PowerchordBase::change_handler(): Not implemented yet!" ); +} + diff --git a/noncore/multimedia/powerchord/powerchordbase.h b/noncore/multimedia/powerchord/powerchordbase.h new file mode 100644 index 0000000..9ff1f44 --- a/dev/null +++ b/noncore/multimedia/powerchord/powerchordbase.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'powerchordbase.ui' +** +** Created: Sun Jan 13 23:04:45 2002 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef POWERCHORDBASE_H +#define POWERCHORDBASE_H + +#include +#include +#include + +#include "gs.h" +#include "gt.h" + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class FretBoard; +class QComboBox; +class QFrame; +class QLabel; +class QListBox; +class QListBoxItem; +class QPushButton; +class QSpinBox; +class QTabWidget; +class VUMeter; + +class PowerchordBase : public QWidget +{ + Q_OBJECT + +public: + PowerchordBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~PowerchordBase(); + + QTabWidget* tabs; + QWidget* tab; + QComboBox* chordkey; + QComboBox* chordfret; + QComboBox* chordnote; + QLabel* s1_1; + QLabel* s1_2; + QLabel* s1_3; + QLabel* s1_4; + QLabel* s1_5; + QLabel* s1_6; + QLabel* sound_label; + QFrame* Frame6; + QLabel* chordshow_label; + QPushButton* transport_rec; + QPushButton* play_sound; + QFrame* Frame6_2; + QPushButton* transport_play; + QPushButton* transport_rew; + QPushButton* transport_fwd; + QLabel* chordname; + FretBoard* frets; + gs* synth; + gt* tuner; + QWidget* tab_2; + QLabel* optlab2; + QComboBox* span; + QLabel* TextLabel1; + QComboBox* tuning; + QLabel* optlab1; + QWidget* Tuner; + QFrame* Frame4; + VUMeter* vu; + QComboBox* tuner_note; + QFrame* Frame8; + QPushButton* tuner_start; + QLabel* tuner_lab1; + QLabel* tuner_lab2; + QComboBox* tuner_calib_note; + QSpinBox* tuner_calib_freq; + QLabel* tuner_lab3; + QLabel* tuner_pic1; + QWidget* tab_3; + QLabel* chordlistlab1; + QListBox* chordlist; + QPushButton* list_remove_btn; + +public slots: + virtual void change_handler(); + + void transport_rec_cb(); + void list_remove_cb(); + void play_chord_cb(); + void tuner_start_cb(); + void tuner_simulation_cb(); + void tuner_cb(); + void audio_cb(); + + signals: + void frequency_change(int); + +protected: + QPixmap image_open; + QPixmap image6; + QTimer *simulation_timer; + QTimer *audio_timer; + int simulation_iter; + int simulation_v; + int simulation_x; + QHBoxLayout* Layout1; +}; + +#endif // POWERCHORDBASE_H diff --git a/noncore/multimedia/powerchord/powerchordbase.ui b/noncore/multimedia/powerchord/powerchordbase.ui new file mode 100644 index 0000000..01dae81 --- a/dev/null +++ b/noncore/multimedia/powerchord/powerchordbase.ui @@ -0,0 +1,1663 @@ + +PowerchordBase + + QWidget + + name + PowerchordBase + + + geometry + + 0 + 0 + 240 + 284 + + + + sizePolicy + + 5 + 5 + + + + minimumSize + + 240 + 284 + + + + maximumSize + + 240 + 284 + + + + caption + Powerchord + + + QTabWidget + + name + tabs + + + enabled + true + + + geometry + + 0 + 0 + 240 + 286 + + + + tabPosition + Bottom + + + QWidget + + name + tab + + + title + Guitar + + + QComboBox + + + text + maj + + + + + text + min + + + + + text + 7th + + + + + text + m7 + + + + + text + maj7 + + + + + text + 6th + + + + + text + m6th + + + + + text + aug + + + + + text + dim + + + + + text + sus4 + + + + + text + 7sus4 + + + + + text + 9th + + + + + text + add9 + + + + + text + m9th + + + + + text + maj9 + + + + + text + sus2 + + + + + text + 7sus2 + + + + + text + 11th + + + + + text + m11th + + + + + text + 13th + + + + + text + m13th + + + + + text + maj13 + + + + + text + 6/9 + + + + + text + flat5 + + + + + text + 7#9 + + + + + text + ø7 + + + + + text + 5 + + + + name + chordkey + + + geometry + + 40 + 0 + 51 + 21 + + + + + QComboBox + + + text + open + + + + + text + 1st + + + + + text + 2nd + + + + + text + 3rd + + + + + text + 4th + + + + + text + 5th + + + + + text + 6th + + + + + text + 7th + + + + + text + 8th + + + + + text + 9th + + + + + text + 10th + + + + + text + 11th + + + + + text + 12th + + + + + text + 13th + + + + + text + 14th + + + + + text + 15th + + + + + text + 16th + + + + name + chordfret + + + geometry + + 90 + 0 + 60 + 21 + + + + + QComboBox + + + text + C + + + + + text + C# + + + + + text + D + + + + + text + Eb + + + + + text + E + + + + + text + F + + + + + text + F# + + + + + text + G + + + + + text + G# + + + + + text + A + + + + + text + Bb + + + + + text + B + + + + name + chordnote + + + geometry + + 0 + 0 + 40 + 21 + + + + currentItem + 9 + + + + QLayoutWidget + + name + Layout1 + + + geometry + + 5 + 232 + 160 + 20 + + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + s1_1 + + + text + E + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + s1_2 + + + text + A + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + s1_3 + + + text + E + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + s1_4 + + + text + A + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + s1_5 + + + text + C# + + + alignment + AlignCenter + + + hAlign + + + + QLabel + + name + s1_6 + + + text + E + + + alignment + AlignCenter + + + hAlign + + + + + + QLabel + + name + sound_label + + + geometry + + 185 + 160 + 32 + 17 + + + + sizePolicy + + 0 + 0 + + + + pixmap + image0 + + + scaledContents + true + + + + QFrame + + name + Frame6 + + + geometry + + 170 + 145 + 66 + 10 + + + + frameShape + HLine + + + frameShadow + Raised + + + + QLabel + + name + chordshow_label + + + geometry + + 185 + 60 + 32 + 17 + + + + sizePolicy + + 0 + 0 + + + + pixmap + image1 + + + scaledContents + true + + + + QPushButton + + name + transport_rec + + + geometry + + 170 + 80 + 30 + 30 + + + + text + + + + pixmap + image2 + + + + QPushButton + + name + play_sound + + + geometry + + 170 + 180 + 60 + 55 + + + + text + + + + pixmap + image3 + + + + QFrame + + name + Frame6_2 + + + geometry + + 170 + 45 + 66 + 10 + + + + frameShape + HLine + + + frameShadow + Raised + + + + QPushButton + + name + transport_play + + + enabled + false + + + geometry + + 200 + 80 + 30 + 30 + + + + text + + + + pixmap + image3 + + + + QPushButton + + name + transport_rew + + + enabled + false + + + geometry + + 170 + 110 + 30 + 30 + + + + text + + + + pixmap + image4 + + + + QPushButton + + name + transport_fwd + + + enabled + false + + + geometry + + 200 + 110 + 30 + 30 + + + + text + + + + pixmap + image5 + + + + QLabel + + name + chordname + + + geometry + + 151 + 0 + 85 + 20 + + + + text + A + + + alignment + AlignCenter + + + hAlign + + + toolTip + + + + + FretBoard + + name + frets + + + geometry + + 0 + 20 + 168 + 210 + + + + + + QWidget + + name + tab + + + title + Options + + + QLabel + + name + optlab2 + + + geometry + + 9 + 58 + 120 + 41 + + + + text + Alternative tunings are possible + + + alignment + WordBreak|AlignVCenter|AlignLeft + + + wordwrap + + + + QComboBox + + + text + 2 + + + + + text + 3 + + + + + text + 4 + + + + + text + 5 + + + + + text + 6 + + + + name + span + + + geometry + + 180 + 20 + 50 + 21 + + + + currentItem + 1 + + + + QLabel + + name + TextLabel1 + + + geometry + + 3 + 109 + 226 + 140 + + + + text + ©2002 Camilo Mesias +camilo@mesias.co.uk +Version 0.0 beta + + + alignment + AlignBottom|AlignLeft + + + vAlign + + + + QComboBox + + + text + EADGBE + + + + + text + EBEG#BE + + + + + text + EAEAC#E + + + + + text + EADF#BE + + + + + text + EADGCF + + + + + text + DADGAD + + + + + text + DGCGCD + + + + + text + DADF#AD + + + + + text + DADGBE + + + + + text + DGDGBD + + + + + text + DADACD + + + + + text + CGCGAE + + + + + text + FADGBE + + + + + text + G minor + + + + name + tuning + + + geometry + + 140 + 70 + 91 + 21 + + + + + QLabel + + name + optlab1 + + + geometry + + 8 + 8 + 160 + 40 + + + + text + Span: the greatest number of frets over which you want chords to be generated + + + alignment + WordBreak|AlignVCenter|AlignLeft + + + wordwrap + + + + + QWidget + + name + Tuner + + + title + Tuner + + + QFrame + + name + Frame4 + + + geometry + + 0 + 0 + 230 + 126 + + + + frameShape + Box + + + frameShadow + Raised + + + VUMeter + + name + vu + + + geometry + + 5 + 5 + 220 + 115 + + + + + + QComboBox + + + text + auto + + + + + text + E + + + + + text + D + + + + + text + G + + + + + text + A + + + + + text + B + + + + + text + C + + + + + text + F + + + + name + tuner_note + + + geometry + + 5 + 160 + 90 + 20 + + + + + QFrame + + name + Frame8 + + + geometry + + -2 + 188 + 231 + 10 + + + + frameShape + HLine + + + frameShadow + Raised + + + + QPushButton + + name + tuner_start + + + geometry + + 100 + 155 + 91 + 30 + + + + text + Start + + + + QLabel + + name + tuner_lab1 + + + geometry + + 10 + 130 + 100 + 21 + + + + text + Tuner operation + + + + QLabel + + name + tuner_lab2 + + + geometry + + 10 + 200 + 100 + 16 + + + + text + Pitch calibration + + + + QComboBox + + + text + A + + + + + text + C + + + + name + tuner_calib_note + + + geometry + + 5 + 225 + 90 + 21 + + + + + QSpinBox + + name + tuner_calib_freq + + + geometry + + 105 + 225 + 71 + 21 + + + + suffix + Hz + + + wrapping + true + + + maxValue + 500 + + + minValue + 300 + + + value + 440 + + + + QLabel + + name + tuner_lab3 + + + geometry + + 185 + 225 + 40 + 21 + + + + text + Pitch + + + + QLabel + + name + tuner_pic1 + + + geometry + + 195 + 155 + 31 + 31 + + + + frameShape + NoFrame + + + pixmap + image6 + + + scaledContents + true + + + + + QWidget + + name + tab + + + title + Chords + + + QLabel + + name + chordlistlab1 + + + geometry + + 5 + 5 + 216 + 16 + + + + text + Chord list + + + + QListBox + + name + chordlist + + + geometry + + 5 + 25 + 220 + 200 + + + + + QPushButton + + name + list_remove_btn + + + geometry + + 150 + 230 + 71 + 25 + + + + text + Remove + + + + + + + + FretBoard +
/src/ZAURUS/powerchord/fretboard.h
+ + -1 + -1 + + 0 + + 5 + 5 + + image7 + Finger(int finger) + s1nameChanged(const QString &) + s2nameChanged(const QString &) + s3nameChanged(const QString &) + s4nameChanged(const QString &) + s5nameChanged(const QString &) + s6nameChanged(const QString &) + nameChanged(const QString &) + Finger() + Base(int) + Chord(int) + Fret(int) + Span(int) + Tune(int) + Vary(int) +
+ + VUMeter +
/src/ZAURUS/powerchord/vumeter.h
+ + -1 + -1 + + 0 + + 5 + 5 + + image7 + Value(int) + AnnotL(QString) + AnnotR(QString) +
+
+ + + image0 + 789c8dd25b6f9b301407f0f77c0a14dea28906b003d6b4875e935e92e6b1d2b407df0894109a4068d369df7d9c636725692acd48e8fcf0df06db9c0d9ca7f9d4199cf5aa9ad7997464ca37ce406d8b62f7f3d78fdfbd7e18387ee410e2f8fd6fbdbee7486756ae34d4aa53f34efdd0a965a776dbda1d62035e5b12436d1927097007f463b880153018c2053c47b2200e18b0b094864b60e88724c46fde20594bec5d594ac32b20f1c990603845724208072e2c63c3374b697803a40191340066867468b845724a2986134b66d800470155230caf0d47be6169490d9f91bc258ebdb46486ef96cab0064661e44721708614118d04505832c33b4b65f8088cc348c5387662d81e0232478a98c5187e0132122b46801786cc371c2325634c02a7404eb8cfb1f7152939e5d87b6fc90de740414420307c8b54622414fe84fbe61eb47f8f31c36d7345a7b9dc93b29351ea64a63b4f1bd1babd7d9a079eca7d0623fa30a33d8521ccd869f471469bb136630999649166cf39be6b1f3ac8682116cb62b9caca17a15d753aa3d79baa2eb74d53bf224f66de8addfba2384fea8baf33e9a6babcaaae9b3aff32239ad5727d5314a5181f7d8ff7b1ae3c4bd3346beac9edd1babcfd44edda274dd294f5ddfdf1feb4e705f503eee1349f3d8ee79ff619cefde4797918f1feebfff9f3bdf7170eba56b0 + + + image1 + 789c8d92cf0ac2300cc6ef7b8ab0dc864caba003f111148f8278485b871e54f0cf41c4777749a3769b8a8141bfe4c79774693783c57c0a5937399de9bc75e0367484cc5f76bbeb7235b925e9a00f660443306927497370303becd77cc6ea8c3d0996566551962c1d4b531019a97a96fd1ead4dc192589612621b07d6835311a3598aa3c5842c7ff5a833ead3f06a30ea23356bff6102f59351ea23639f4ce8f79dd1464f467e95dce8ddcb3619e73147efb0c5bce7a9ca1e2bd06134b322914f057986e27bd519290ba87ba01744910f8686f4da5963173c6e1e06d76c7ba77af7cf8f87dfc67d9c3c003050bd05 + + + image2 + 789c7d90cb0ac2301045f7fd8ad0ec8aa48da808e227282e057191c9a30fa882d68588ff6e264deab89166a6e7a6873c5a16ec78d8b1a2ccee831a5acd74a36eac308fbe7f9ecedb5796cb15c33167329f653930cdf6d78b45ae091bc21d6145981316843561eb999ba5ac6485d1c5b818633bc535c626449ba2e042d10afb03f8e03bf82e40070f306203ee59470fc058675d8d34798d6d2d167cbd60453379d1f2f5f55cf22cf1d27acd7faf4eeb75e47cc9a3e71bcd0e80de237c00bc75f2f08fe0947f474ffc3ef97b937d00c5a693bc + + + image3 + 789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022530543251d2ea544856405bffcbc54105b1989ad87c44e46622701d9ca06600056a6ac97888cc1462625013970980c569704040895c950752080a90e04202a91d5c1d4a2aa83988bae0e0430d541c550d4619a87ee3e980b91d5c17c825087e95fe49081a8d343854ab5d65c00c02d7422 + + + image4 + 789c6d903d0a02311085fb9c6248ba4566b5b1118fa0580a6231792b68a182ae858877773291dd2c64924c5e3e5e263f6d43fbdd869ad63d7be92f209ce5414df7ba5edf87e3fae3fc6249da35f999f39140dbfbed94b4143a149a0bdd155a6b53985b982db094c34ac6a80b418c9a199df9a28640590c8ccc2431184bd3e04366c0e84366c0e8436618996012d9576152d9cb9533a47217aedcd9dec1c6f4d5832ffd88b2f42b7f1f4f9bffaedc0f5a767fcf + + + image5 + 789c6d8fc10ac2300c86ef7d8ad2de8a647af1223e82e251100f692ae8610a3a0f22bebb49bab90cecb6fe7ffe7d5b9326f9fd6ee353e31e1d7617f274c6bb4fe5d9b6afc371fd7661b1f47cf316662ef07bbfbd5d4fe2d1f8683c185f8ccfece35c976211d03efacb4c5c2064921d8b723913979145c852390909440ca7a14a1c3909ab188eab5e0cf75b969b64f8e75b989c61ce1d7a31fd71a4adc3d81fc9c4b9cedd733a67546a9817a657f8acdc17f87f7bda + + + image6 + 789c9593dd739a4010c0dffd2b1879733a1710509c4e1fa2e683f8111f3bd3e903701048505130c464fabf97ddbd9343d34e7be8b83fdcfdb177c75df5b4efab85d6bbea14a55fa6a11626fe5eebf1c37a7dfcf1f3db47a76b995afdb16dcdec7ee974a75aa82db79b08e28512df2971a5c49e122f9578aec4a912174a3c5162a6c4511deb060ec031a06ddab68d1d1e107dc3355cc09dc090704d5827fb80994097f019d0f1a58a030eada139b4004b810ee11131300d13db7825b45c6b049813d6c901e00da06b0d46037cd03be0c8365d13bb7a2374460efe1b0206b619f6d11c23722b24f383446a7246681b84d780a1d337a8768fc825de0ab4fba8da0a7409ef01b9d30f095f245a680e1023a9d205da84ab1362ad0f180d243e113a86d3077c448c069c56720318c7d1201a0026843070ebff3efe3f45f7e5f587143df083e6fb494a63689b9a14511bf28847b170b553a8ee29e27831c52353c8c112cae070477a648aa849a445dcd19b1472b0c69236f3922975450243589e5f9a59510ae6273c5b2734365b70a4e4a6147c6a9233c62318bb3dd417e2beb040ef493d8f12320ed8c7ab986763a95bcdab0a2c3bece12d13abd5f4c2a4e5888eb45ce35aa8bd30d1cb3b38f605e3e7165d588a181cd769ed1b8bbd5767c4f26ca293635ac7156bcf08d796dfdc521fd369c9b33bb14f8ac567937bfc2da63ce7995789dd57f7a8c0357ee0252fc798c12ef608af191832e6cdabd3eeb7df97c05f8063e92d17e4b8785f74df9b531fd5e5fb226af447e8a4be32710edaaf3755ade2bcf6ccf493a37548d433d438ce8fda27a7e8fcc07a9767f1df8efdafaf9ddf36a4a563 + + + image7 + 789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758 + + + + + chordnote + activated(int) + frets + Base(int) + + + chordkey + activated(int) + frets + Chord(int) + + + chordfret + activated(int) + frets + Fret(int) + + + list_remove_btn + clicked() + chordlist + clearSelection() + + + frets + s1nameChanged(const QString &) + s1_1 + setText(const QString&) + + + frets + s2nameChanged(const QString &) + s1_2 + setText(const QString&) + + + frets + s3nameChanged(const QString &) + s1_3 + setText(const QString&) + + + frets + s4nameChanged(const QString &) + s1_4 + setText(const QString&) + + + frets + s5nameChanged(const QString &) + s1_5 + setText(const QString&) + + + frets + s6nameChanged(const QString &) + s1_6 + setText(const QString&) + + + frets + nameChanged(const QString &) + chordname + setText(const QString&) + + change_handler() + +
diff --git a/noncore/multimedia/powerchord/vumeter.cpp b/noncore/multimedia/powerchord/vumeter.cpp new file mode 100644 index 0000000..0c17435 --- a/dev/null +++ b/noncore/multimedia/powerchord/vumeter.cpp @@ -0,0 +1,105 @@ +// +// VUMeter class +// + +// Copyright (c) 2001 Camilo Mesias +// camilo@mesias.co.uk +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include "vumeter.h" +#include + +#include + +VUMeter::VUMeter(QWidget *parent, const char *name ) + : QWidget( parent, name ), Lannot("A"), Rannot("440 Hz") +{ + // setPalette( QPalette( QColor( 250, 250, 200) ) ); + + vuvalue = 0; + + pix = 0; + + +} + +VUMeter::~VUMeter() +{ + delete(pix); +} + +void VUMeter::paintEvent(QPaintEvent *){ + + vupdate(); +} + +void VUMeter::bupdate(){ + + if (!pix){ + pix = new QPixmap(rect().size()); + } + // redraw whole background to buffer + + pix->fill(this, 0, 0); + + QPainter p( pix ); + + p.setBrush(white); + p.setPen(NoPen); + + p.drawRect( QRect(0, 0, width(), height()) ); + + p.translate(width()/2, 0); + + p.setBrush(black); + p.setPen(black); + + // for (int i=-50;i<50;i+=4){ + // p.drawLine((vuvalue), height()-10, vuvalue*2, 25); + // } + + p.drawText(-100,15,Lannot); + p.drawText(65,15,Rannot); + + p.drawText(-100, height()-25, QString("-")); + p.drawText(85, height()-25, QString("+")); + p.drawText(-2, 20, QString("0")); + p.end(); + +} + +void VUMeter::vupdate(){ + + if (!pix){ + bupdate(); + } + + // redraw line only + + QPixmap tmp_pix(rect().size()); + + QPainter p( &tmp_pix ); + p.drawPixmap(QPoint(0,0), *pix); + + p.translate(width()/2, 0); + p.drawLine((vuvalue), height()-10, vuvalue*2, 25); + p.end(); + bitBlt(this, rect().topLeft(), &tmp_pix); +} + + + diff --git a/noncore/multimedia/powerchord/vumeter.h b/noncore/multimedia/powerchord/vumeter.h new file mode 100644 index 0000000..d708435 --- a/dev/null +++ b/noncore/multimedia/powerchord/vumeter.h @@ -0,0 +1,59 @@ +// +// VUMeter class +// + +// Copyright (c) 2001 Camilo Mesias +// camilo@mesias.co.uk +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __VUMETER_H +#define __VUMETER_H + +#include +#include +#include + +class VUMeter : public QWidget { + + Q_OBJECT + + private: + int vuvalue; + QString Lannot; + QString Rannot; + + QPixmap *pix; + + protected: + void paintEvent(QPaintEvent *); + void bupdate(); + void vupdate(); + + public: + VUMeter(QWidget *parent=0, const char *name=0); + ~VUMeter(); + + // slots + public slots: + void Value(int x){vuvalue = x; vupdate(); }; + void AnnotL(const QString &s){Lannot = s; bupdate(); }; + void AnnotR(const QString &s){Rannot = s; bupdate(); }; +}; + +#endif + + + -- cgit v0.9.0.2