Skip to content

Commit

Permalink
Piano fix; Added modes
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown authored and Unknown committed Aug 13, 2019
1 parent d2f60dc commit 969c97d
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 18 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ There are currently no configuration options.
Usage
-----

Usage is similar to muddyGB, but with some big changes planned.
Usage is similar to muddyGB, but with a much different method of playing.

* The directional pad acts to play the notes of the chosen scale.
* The START button raises and lowers the scale by an octave.
* The B button enables portamento between notes
* The A button performs a fixed vibrato
* The START button raise the pitch by an octave
* The SELECT button lower the pitch by an octave
* The START button raises the pitch by an octave
* The SELECT button lowers the pitch by an octave
* while SELECT + START pressed got the options mode
* + RIGHT selects the current mode.
* + UP or DOWN selects the scale tonic (base note).
Expand Down Expand Up @@ -49,9 +48,8 @@ For future versions

minestones for v1.0:

* add graphical options menu
* enter by pressing key combination
* Change options behavior to edit options with only the select key.
* Fix the Piano to go up and down octaves, and shift around

* fix waveform selection
* add echo mode to pulse wave
* add selectable envelopes (volume, pitch and pulse width)
Binary file modified gfx/pianolayout.gbm
Binary file not shown.
Binary file modified gfx/pianoroll2.gbr
Binary file not shown.
21 changes: 20 additions & 1 deletion gfx/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,23 @@ const int HUDPositions[] = {
1,3,
1,5,
1,7
};
};

const unsigned char PianoNotesDown[][4] = {
{0x65, 0x66, 0x62, 0x61 }, // C
{0x64, 0x67, 0x61, 0x61 }, // C#
{0x68, 0x6A, 0x62, 0x61 }, // D
{0x69, 0x6B, 0x61, 0x61 }, // D#
{0x6C, 0x63, 0x62, 0x61}, // E
{0x65, 0x66, 0x62, 0x61 }, // F
{0x64, 0x67, 0x61, 0x61 }, // F#
{0x68, 0x66, 0x62, 0x61 }, // G
{0x64, 0x67, 0x61, 0x61 }, // G#
{0x68, 0x6A, 0x62, 0x61 }, // A
{0x69, 0x6B, 0x61, 0x61 }, // A#
{0x6C, 0x63, 0x62, 0x61}, // B
};

const unsigned int PianoOffset[] = {
0,0,1,1,2,3,3,4,4,5,5,6
};
25 changes: 20 additions & 5 deletions muddygb_dsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ void main() {
UBYTE keys;
UBYTE pos, old_pos = 0;
int note = 0;
int noteInt = 0; // Used for the piano
int oldNoteMap[4] = {0,0,0,0};
int octave_min = 0;
int octave_max = 3;
int relative_octave = 0;
Expand Down Expand Up @@ -86,9 +88,8 @@ void main() {
keys = joypad ();
pos = scale_position (keys);
jp = just_pressed(keys);
//if (jp != 0) printf("%d\n", jp);

if (pos) {
if (pos) { // Check for A and B keys here.
note = scale[pos - 1] + relative_octave*OCTAVE_LEN;

/* Lower by semitone */
Expand Down Expand Up @@ -218,18 +219,27 @@ void main() {
printf(note_names[note % OCTAVE_LEN]);
else
printf(note_names[note + OCTAVE_LEN]);



absolute_octave = note / OCTAVE_LEN + 3;
printf("%d", absolute_octave);

gotoxy(0, 16);
noteInt = note % OCTAVE_LEN;


set_bkg_tiles(0, 16, PianoLayoutWidth, PianoLayoutHeight, PianoLayout);
set_bkg_tiles(7 + PianoOffset[noteInt],16,2,2, PianoNotesDown[noteInt]);

//printf(" ");
//font_set(big_font);
} else {
/* Stop note */
CH1_VOL = OFF;
CH2_VOL = OFF;
targetNote = 0;
set_bkg_tiles(0, 16, PianoLayoutWidth, PianoLayoutHeight, PianoLayout);
}
}

Expand Down Expand Up @@ -331,15 +341,20 @@ void play_note (short note, UBYTE waveform, short bend, int newNote ) {
#define BUILD(TYPE) \
gotoxy(HUDPositions[4], HUDPositions[5]); \
printf ("mode %s", note_names[tonic]); \
printf ("%s ", #TYPE); \
printf ("%s ", #TYPE); \
build_scale (scale, tonic, TYPE); \
break;

void build_scale_mode (UBYTE * scale, UBYTE tonic, UBYTE mode) {
switch (mode) {
case 0: BUILD (major);
case 1: BUILD (minor);
case 2: BUILD (blues);
case 1: BUILD (dorian);
case 2: BUILD (phrygian);
case 3: BUILD (lydian);
case 4: BUILD (myxolydian);
case 5: BUILD (minor);
case 6: BUILD (locrian);
case 7: BUILD (blues);
}
}

Expand Down
4 changes: 2 additions & 2 deletions muddygb_dsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#ifndef BOUEUX_H
#define BOUEUX_H

#define MUDDYGBRVL_VERSION "0.1a"
#define MUDDYGBRVL_VERSION "0.3a"

#define UINT unsigned int
#define UBYTE unsigned char
#define SCALE UBYTE

#define NUM_MODES 3
#define NUM_MODES 8
#define OCTAVE_LEN 12

#define PRESSED(KEY) (keys & J_## KEY)
Expand Down
5 changes: 5 additions & 0 deletions music.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ const char* note_names[] = {


extern SCALE major[];
extern SCALE dorian[];
extern SCALE phrygian[];
extern SCALE lydian[];
extern SCALE myxolydian[];
extern SCALE minor[];
extern SCALE locrian[];
extern SCALE blues[];

void build_scale (UBYTE * scale, UBYTE tonic, SCALE * scale_type);
Expand Down
8 changes: 5 additions & 3 deletions scales.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
*/

SCALE major[] = { C, D, E, F, G, A, B, C2 };
SCALE dorian[] = { C, D, Ds, F, G, A, As, C2 };
SCALE phrygian[] = { C, Cs, Ds, F, G, Gs, As, C2 };
SCALE lydian[] = { C, D, E, Fs, G, A, B, C2 };
SCALE myxolydian[] = { C, D, E, F, G, A, As, C2 };
SCALE minor[] = { C, D, Ds, F, G, Gs, As, C2 };
SCALE locrian[] = { C, Cs, Ds, F, Fs, Gs, As, C2 };
SCALE blues[] = { C, Ds, F, Fs, G, As, C2, Ds2 };

//SCALE harmonic[] = { C, D, Ds, F, G, Gs, B, C2 };
//SCALE wholetone[] = { C, D, E, Fs, Gs, As, C2, D2 };

//SCALE dorian[] = { C, D, Ds, F, G, A, As, C2 };
//SCALE lydian[] = { C, D, E, Fs, G, A, B, C2 };

/* The 'blue' scale uses quarter-tones. (see music.c.)
* It is equivalent to C, D, Ed, F, G, A, Bd, C2.
*/

0 comments on commit 969c97d

Please sign in to comment.