Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added scales #128

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ COMMONFILES := \
MessageBox.o \
GrooveView.o UINoteVarField.o UIBigHexVarField.o \
SRPUpdaters.o UIStaticField.o \
Song.o Chain.o Phrase.o Project.o \
Song.o Chain.o Phrase.o Project.o Scale.o \
char.o n_assert.o fixed.o wildcard.o \
SyncMaster.o TablePlayback.o Player.o \
Table.o TableView.o\
Expand Down
8 changes: 8 additions & 0 deletions projects/lgpt.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,14 @@
RelativePath="..\sources\Application\Model\Song.h"
>
</File>
<File
RelativePath="..\sources\Application\Model\Scale.cpp"
>
</File>
<File
RelativePath="..\sources\Application\Model\Scale.h"
>
</File>
<File
RelativePath="..\sources\Application\Model\Table.cpp"
>
Expand Down
2 changes: 2 additions & 0 deletions projects/lgpt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
<ClCompile Include="..\sources\Application\Model\Project.cpp" />
<ClCompile Include="..\sources\Application\Model\Song.cpp" />
<ClCompile Include="..\sources\Application\Model\Table.cpp" />
<ClCompile Include="..\sources\Application\Model\Scale.cpp" />
<ClCompile Include="..\sources\UIFramework\BasicDatas\FontConfig.cpp" />
<ClCompile Include="..\sources\Application\views\ChainView.cpp" />
<ClCompile Include="..\sources\Application\views\ConsoleView.cpp" />
Expand Down Expand Up @@ -408,6 +409,7 @@
<ClInclude Include="..\sources\Application\Model\Project.h" />
<ClInclude Include="..\sources\Application\Model\Song.h" />
<ClInclude Include="..\sources\Application\Model\Table.h" />
<ClInclude Include="..\sources\Application\Model\Scale.h" />
<ClCompile Include="..\sources\UIFramework\BasicDatas\FontConfig.h" />
<ClInclude Include="..\sources\Application\views\ChainView.h" />
<ClInclude Include="..\sources\Application\views\ConsoleView.h" />
Expand Down
6 changes: 6 additions & 0 deletions projects/lgpt64.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
A95153FD2C88A4E70060FA44 /* SDLTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A95153FB2C88A4E60060FA44 /* SDLTimer.cpp */; };
A95154012C88A6670060FA44 /* MacOSmain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A95153FE2C88A6670060FA44 /* MacOSmain.cpp */; };
A95154052C88A6720060FA44 /* MacOSSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A95154042C88A6720060FA44 /* MacOSSystem.cpp */; };
A9A67DC42C9629AF00E923CD /* Scale.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A9A67DC32C9629AF00E923CD /* Scale.cpp */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -512,6 +513,8 @@
A95153FE2C88A6670060FA44 /* MacOSmain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MacOSmain.cpp; path = ../MacOS/MacOSMain/MacOSmain.cpp; sourceTree = "<group>"; };
A95154032C88A6720060FA44 /* MacOSSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MacOSSystem.h; path = ../../MacOS/MacOSSystem/MacOSSystem.h; sourceTree = "<group>"; };
A95154042C88A6720060FA44 /* MacOSSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MacOSSystem.cpp; path = ../../MacOS/MacOSSystem/MacOSSystem.cpp; sourceTree = "<group>"; };
A9A67DC22C9629AF00E923CD /* Scale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scale.h; sourceTree = "<group>"; };
A9A67DC32C9629AF00E923CD /* Scale.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Scale.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -758,6 +761,8 @@
737D11A20BCE66F000099CB3 /* Model */ = {
isa = PBXGroup;
children = (
A9A67DC32C9629AF00E923CD /* Scale.cpp */,
A9A67DC22C9629AF00E923CD /* Scale.h */,
87CA0EA80F7E1160001D6BD0 /* Mixer.cpp */,
87CA0EA90F7E1160001D6BD0 /* Mixer.h */,
73A640190D3CF90A00F43955 /* Groove.cpp */,
Expand Down Expand Up @@ -1496,6 +1501,7 @@
737D128D0BCE66F000099CB3 /* UIController.cpp in Sources */,
737D128E0BCE66F000099CB3 /* ViewData.cpp in Sources */,
737D12900BCE66F000099CB3 /* Observable.cpp in Sources */,
A9A67DC42C9629AF00E923CD /* Scale.cpp in Sources */,
737D12940BCE66F000099CB3 /* Service.cpp in Sources */,
737D12950BCE66F000099CB3 /* ServiceRegistry.cpp in Sources */,
737D12960BCE66F000099CB3 /* SubService.cpp in Sources */,
Expand Down
13 changes: 13 additions & 0 deletions sources/Application/Model/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "System/io/Status.h"
#include "Foundation/Variables/WatchedVariable.h"
#include "Application/Player/SyncMaster.h"
#include "Scale.h"
#include "Table.h"
#include "Groove.h"
#include "Application/Persistency/PersistencyService.h"
Expand All @@ -27,6 +28,11 @@ tempoNudge_(0)
this->Insert(wrap) ;
Variable *transpose=new Variable("transpose",VAR_TRANSPOSE,0) ;
this->Insert(transpose) ;

// from: https://github.com/xiphonics/picoTracker/blob/master/sources/Application/Model/Project.cpp
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if we keep this info in the corresponding .h and .cpp, it's not necessary to have it here.

Variable *scale = new Variable("scale", VAR_SCALE, scaleNames, scaleCount, 0);
this->Insert(scale);
scale->SetInt(0);

// Reload the midi device list

Expand Down Expand Up @@ -59,6 +65,13 @@ Project::~Project() {
delete instrumentBank_ ;
} ;

// from: https://github.com/xiphonics/picoTracker/blob/master/sources/Application/Model/Project.cpp
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if we keep this info in the corresponding .h and .cpp, it's not necessary to have it here.

int Project::GetScale() {
Variable *v = FindVariable(VAR_SCALE);
NAssert(v);
return v->GetInt();
}

int Project::GetTempo() {
Variable *v=FindVariable(VAR_TEMPO) ;
NAssert(v) ;
Expand Down
2 changes: 2 additions & 0 deletions sources/Application/Model/Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define VAR_WRAP MAKE_FOURCC('W','R','A','P')
#define VAR_MIDIDEVICE MAKE_FOURCC('M','I','D','I')
#define VAR_TRANSPOSE MAKE_FOURCC('T','R','S','P')
#define VAR_SCALE MAKE_FOURCC('S', 'C', 'A', 'L')

#define PROJECT_NUMBER "1"
#define PROJECT_RELEASE "4"
Expand All @@ -35,6 +36,7 @@ class Project: public Persistent,public VariableContainer,I_Observer {
bool Wrap() ;
void OnTempoTap();
void NudgeTempo(int value) ;
int GetScale();
int GetTempo() ; // Takes nudging into account
int GetTranspose() ;

Expand Down
199 changes: 199 additions & 0 deletions sources/Application/Model/Scale.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
// from: https://github.com/xiphonics/picoTracker
#include "Scale.h"

// Source of scales in original release:
// https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/PitchConstellations.svg/1280px-PitchConstellations.svg.png

// Additional Scales
// https://pianoencyclopedia.com/scales/

const char *scaleNotes[scaleNoteCount] = {
"C","C#","D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
};

const char *scaleNames[scaleCount] = {"None (Chromatic)",
"Acoustic",
"Adonal malakh",
"Aeolian mode (minor)",
"Algerian",
"Altered",
"Augmented",
"Bebop dominant",
"Blues",
"Dorian",
"Double harmonic",
"Enigmatic",
"Flamenco",
"Gypsy",
"Half diminished",
"Harmonic major",
"Harmonic minor",
"Hirajoshi",
"Hungarian gypsy",
"Hungarian minor",
"Insen",
"Ionian mode (major)",
"Istrian",
"Iwato",
"Locrian",
"Lydian augmented",
"Lydian",
"Major bebop",
"Major locran",
"Major pentatonic",
"Melodic minor",
"Melodic minor (asc)",
"Minor pentatonic",
"Mixolydian",
"Neapolitan major",
"Neapolitan minor",
"Octatonic",
"Persian",
"Phrygian dominant",
"Phrygian",
"Prometheus",
"Ryukyu",
"Tritone",
"Tercera Alta",
"Ukranian",
"Whole tone",
};

const bool scaleSteps[scaleCount][scaleNoteCount] = {
// "C","C#","D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
// "None (Chromatic)"
{true, true, true, true, true, true, true, true, true, true, true, true},
// "Acoustic"
{true, false, true, false, true, false, true, true, false, true, false,
false},
// "Adonal malakh"
{true, false, true, false, true, true, false, true, true, false, true,
false},
// "Aeolian mode (minor)"
{true, false, true, true, false, true, false, true, true, false, true,
false},
// "Algerian"
{true, false, true, true, false, false, true, true, true, false, false,
true},
// "Altered"
{true, true, false, true, true, false, true, false, true, false, true,
false},
// "Augmented"
{true, false, false, true, true, false, false, true, true, false, false,
true},
// "Bebop dominant"
{true, false, true, false, true, true, false, true, false, true, true,
true},
// "Blues"
{true, false, false, true, false, true, true, true, false, false, true,
false},
// "Dorian"
{true, false, true, true, false, true, false, true, false, true, true,
false},
// "Double harmonic"
{true, true, false, false, true, true, false, true, true, false, false,
true},
// "Enigmatic"
{true, true, false, false, true, false, true, false, true, false, true,
true},
// "Flamenco"
{true, true, false, false, true, true, false, true, true, false, false,
true},
// "Gypsy"
{true, false, true, true, false, false, true, true, true, false, true,
false},
// "Half diminished"
{true, false, true, true, false, true, true, false, true, false, true,
false},
// "Harmonic major"
{true, false, true, false, true, true, false, true, true, false, false,
true},
// "Harmonic minor"
{true, false, true, true, false, true, false, true, true, false, false,
true},
// "Hirajoshi"
{true, false, true, true, false, false, false, true, true, false, false,
false},
// "Hungarian gypsy"
{true, false, true, true, false, false, true, true, true, false, false,
true},
// "Hungarian minor"
{true, false, true, true, false, false, true, true, true, false, false,
true},
// "Insen"
{true, true, false, false, false, true, false, true, false, false, true,
false},
// "Ionian mode (major)"
{true, false, true, false, true, true, false, true, false, true, false,
true},
// "Istrian"
{true, true, false, true, true, false, true, true, false, false, false,
false},
// "Iwato"
{true, true, false, false, false, true, true, false, false, false, true,
false},
// "Locrian"
{true, true, false, true, false, true, true, false, true, false, true,
false},
// "Lydian augmented"
{true, false, true, false, true, false, true, false, true, true, false,
true},
// "Lydian"
{true, false, true, false, true, false, true, true, false, true, false,
true},
// "Major bebop"
{true, false, true, false, true, true, false, true, true, true, false,
true},
// "Major locran"
{true, false, true, false, true, true, true, false, true, false, true,
false},
// "Major pentatonic"
{true, false, true, false, true, false, false, true, false, true, false,
false},
// "Melodic minor"
{true, false, true, true, false, true, false, true, true, true, true, true},
// "Melodic minor (asc)"
{true, false, true, true, false, true, false, true, false, true, false,
true},
// "Minor pentatonic"
{true, false, false, true, false, true, false, true, false, false, true,
false},
// "Mixolydian"
{true, false, true, false, true, true, false, true, false, true, true,
false},
// "Neapolitan major"
{true, true, false, true, false, true, false, true, false, true, false,
true},
// "Neapolitan minor"
{true, true, false, true, false, true, false, true, true, false, false,
true},
// "Octatonic"
{true, false, true, true, false, true, true, false, true, true, false,
true},
// "Persian"
{true, true, false, false, true, true, true, false, true, false, false,
true},
// "Phrygian dominant"
{true, true, false, false, true, true, false, true, true, false, true,
false},
// "Phrygian"
{true, true, false, true, false, true, false, true, true, false, true,
false},
// "Prometheus"
{true, false, true, false, true, false, true, false, false, true, true,
false},
// Ryukyu
{true, false, false, false, true, true, false, true, false, false, false, true},
// "Tritone"
{true, true, false, false, true, false, true, true, false, false, true,
false},
// "Tercera Alta"
{false, true, true, false, false, false, true, false, false, true, false, false},
// "Ukranian"
{true, false, true, true, false, false, true, true, false, true, true,
false},
// "Whole tone"
{true, false, true, false, true, false, true, false, true, false, true,
false}

};
11 changes: 11 additions & 0 deletions sources/Application/Model/Scale.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// from: https://github.com/xiphonics/picoTracker
#ifndef SCALE_VIEW_H
#define SCALE_VIEW_H

const int scaleCount = 46;
const int scaleNoteCount = 12;
extern const char *scaleNames[scaleCount];
extern const char *scaleNotes[scaleNoteCount];
extern const bool scaleSteps[scaleCount][scaleNoteCount];

#endif
29 changes: 29 additions & 0 deletions sources/Application/Views/PhraseView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Application/Utils/char.h"
#include "Application/Instruments/CommandList.h"
#include "UIController.h"
#include "Application/Model/Scale.h"
#include "Application/Model/Table.h"
#include "Application/Utils/HelpLegend.h"
#include <string.h>
Expand Down Expand Up @@ -206,6 +207,12 @@ void PhraseView::updateCursorValue(ViewUpdateDirection direction,int xOffset,int
}
if ((c)&&(*c!=0xFF)) {
int offset=offsets_[col_+xOffset][direction] ;
// from: https://github.com/xiphonics/picoTracker/blob/master/sources/Application/Views/PhraseView.cpp
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if we keep this info in the corresponding .h and .cpp, it's not necessary to have it here.

// Add/remove from offset to match selected scale
int scale = viewData_->project_->GetScale();
while (!scaleSteps[scale][(*c + offset) % 12]) {
offset > 0 ? offset++ : offset--;
}

updateData(c,offset,limit,wrap) ;
switch(col_+xOffset) {
Expand Down Expand Up @@ -1011,6 +1018,7 @@ void PhraseView::DrawView() {
sprintf(title,"Phrase %2.2x",viewData_->currentPhrase_) ;
DrawString(pos._x,pos._y,title,props) ;


// Compute song grid location

GUIPoint anchor=GetAnchor() ;
Expand Down Expand Up @@ -1178,6 +1186,27 @@ void PhraseView::DrawView() {

drawMap() ;
drawNotes() ;

// Draw Current Scale
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no commits containing commented-out code

// Uncomment if you want to display the current scale in phrase view
/*
int scale = viewData_->project_->GetScale();
if (scale > 0) {
// Only Draw Scales different from default (chromatic)
char scale_notes_title[25];
std::string scale_notes = "";

for(int i = 0; i < scaleNoteCount; i++) {
if (scaleSteps[scale][i] == true) {
scale_notes = scale_notes + scaleNotes[i];
};
}

SetColor(CD_NORMAL);
sprintf(scale_notes_title, "Scale: %s", scale_notes.c_str());
DrawString(0, pos._y + 4, scale_notes_title, props);
}
*/

Player *player=Player::GetInstance() ;
if (player->IsRunning()) {
Expand Down
Loading
Loading