mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
Fixed accidental handling in songs with key changes
This commit is contained in:
parent
2d33c80489
commit
3126ae3b03
|
@ -109,9 +109,9 @@ enum VLRecalc {
|
||||||
- (VLSong *) song;
|
- (VLSong *) song;
|
||||||
- (NSImage *) musicElement:(VLMusicElement)elt;
|
- (NSImage *) musicElement:(VLMusicElement)elt;
|
||||||
|
|
||||||
- (int) stepWithPitch:(int)pitch;
|
- (int) stepInSection:(int)section withPitch:(int)pitch;
|
||||||
- (float) systemY:(int)system;
|
- (float) systemY:(int)system;
|
||||||
- (float) noteYWithPitch:(int)pitch accidental:(VLMusicElement*)accidental;
|
- (float) noteYInSection:(int)section withPitch:(int)pitch accidental:(VLMusicElement*)accidental;
|
||||||
- (float) noteYInMeasure:(int)measure withPitch:(int)pitch accidental:(VLMusicElement*)accidental;
|
- (float) noteYInMeasure:(int)measure withPitch:(int)pitch accidental:(VLMusicElement*)accidental;
|
||||||
- (float) noteXInMeasure:(int)measure at:(VLFraction)at;
|
- (float) noteXInMeasure:(int)measure at:(VLFraction)at;
|
||||||
|
|
||||||
|
|
|
@ -173,30 +173,33 @@ VLMusicElement sSemi2Accidental[12][12] = {
|
||||||
#undef N
|
#undef N
|
||||||
#undef _
|
#undef _
|
||||||
|
|
||||||
- (int) stepWithPitch:(int)pitch
|
- (int) stepInSection:(int)section withPitch:(int)pitch
|
||||||
{
|
{
|
||||||
int semi = pitch % 12;
|
int semi = pitch % 12;
|
||||||
int key = [self song]->fProperties.front().fKey;
|
int key = [self song]->fProperties[section].fKey;
|
||||||
bool useSharps = key > 0;
|
bool useSharps = key > 0;
|
||||||
|
|
||||||
return sSemi2Pitch[useSharps][semi];
|
return sSemi2Pitch[useSharps][semi];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) noteYWithPitch:(int)pitch accidental:(VLMusicElement*)accidental
|
- (float) noteYInSection:(int)section
|
||||||
|
withPitch:(int)pitch accidental:(VLMusicElement*)accidental
|
||||||
{
|
{
|
||||||
int semi = pitch % 12;
|
int semi = pitch % 12;
|
||||||
int octave = (pitch / 12) - 5;
|
int octave = (pitch / 12) - 5;
|
||||||
int key = [self song]->fProperties.front().fKey;
|
int key = [self song]->fProperties[section].fKey;
|
||||||
|
|
||||||
*accidental = sSemi2Accidental[key+6][semi];
|
*accidental = sSemi2Accidental[key+6][semi];
|
||||||
|
|
||||||
return (octave*3.5f+[self stepWithPitch:pitch]*0.5f-1.0f)*kLineH;
|
return (octave*3.5f
|
||||||
|
+ [self stepInSection:section withPitch:pitch]*0.5f-1.0f)*kLineH;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) noteYInMeasure:(int)measure withPitch:(int)pitch accidental:(VLMusicElement*)accidental
|
- (float) noteYInMeasure:(int)measure withPitch:(int)pitch accidental:(VLMusicElement*)accidental
|
||||||
{
|
{
|
||||||
return [self systemY:fLayout->SystemForMeasure(measure)]
|
return [self systemY:fLayout->SystemForMeasure(measure)]
|
||||||
+ [self noteYWithPitch:pitch accidental:accidental];
|
+ [self noteYInSection:[self song]->fMeasures[measure].fPropIdx
|
||||||
|
withPitch:pitch accidental:accidental];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) noteXInMeasure:(int)measure at:(VLFraction)at
|
- (float) noteXInMeasure:(int)measure at:(VLFraction)at
|
||||||
|
@ -716,7 +719,10 @@ static int8_t sSharpAcc[] = {
|
||||||
fCursorAccidental = kMusicExtendCursor;
|
fCursorAccidental = kMusicExtendCursor;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const VLProperties & prop = [self song]->fProperties.front();
|
int cursorSection =
|
||||||
|
[self song]->fMeasures[fCursorMeasure].fPropIdx;
|
||||||
|
const VLProperties & prop =
|
||||||
|
[self song]->fProperties[cursorSection];
|
||||||
|
|
||||||
if (prop.fKey >= 0) {
|
if (prop.fKey >= 0) {
|
||||||
if (prop.fKey >= sSharpAcc[fCursorPitch % 12]) { // Sharp in Key
|
if (prop.fKey >= sSharpAcc[fCursorPitch % 12]) { // Sharp in Key
|
||||||
|
|
|
@ -49,11 +49,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawLedgerLinesWithPitch:(int)pitch at:(NSPoint)p
|
- (void) drawLedgerLinesInSection:(int)section withPitch:(int)pitch at:(NSPoint)p
|
||||||
{
|
{
|
||||||
p.x += kLedgerX;
|
p.x += kLedgerX;
|
||||||
int octave = (pitch / 12) - 5;
|
int octave = (pitch / 12) - 5;
|
||||||
int step = (octave*7+[self stepWithPitch:pitch]-2)/2;
|
int step = (octave*7+[self stepInSection:section withPitch:pitch]-2)/2;
|
||||||
|
|
||||||
for (int i=0; i-- > step; ) {
|
for (int i=0; i-- > step; ) {
|
||||||
NSPoint p0 = p;
|
NSPoint p0 = p;
|
||||||
|
@ -75,6 +75,7 @@
|
||||||
{
|
{
|
||||||
int cursorX;
|
int cursorX;
|
||||||
int cursorY;
|
int cursorY;
|
||||||
|
int cursorSect;
|
||||||
VLMusicElement accidental;
|
VLMusicElement accidental;
|
||||||
VLMusicElement cursorElt;
|
VLMusicElement cursorElt;
|
||||||
|
|
||||||
|
@ -91,7 +92,8 @@
|
||||||
cursorY =
|
cursorY =
|
||||||
[self noteYInMeasure:fCursorMeasure
|
[self noteYInMeasure:fCursorMeasure
|
||||||
withPitch:fCursorPitch accidental:&accidental] - kNoteY;
|
withPitch:fCursorPitch accidental:&accidental] - kNoteY;
|
||||||
[self drawLedgerLinesWithPitch:fCursorPitch
|
cursorSect = [self song]->fMeasures[fCursorMeasure].fPropIdx;
|
||||||
|
[self drawLedgerLinesInSection:cursorSect withPitch:fCursorPitch
|
||||||
at:NSMakePoint(cursorX,
|
at:NSMakePoint(cursorX,
|
||||||
[self systemY:fLayout->SystemForMeasure(fCursorMeasure)])];
|
[self systemY:fLayout->SystemForMeasure(fCursorMeasure)])];
|
||||||
cursorElt = kMusicNoteCursor;
|
cursorElt = kMusicNoteCursor;
|
||||||
|
@ -301,15 +303,17 @@
|
||||||
&& note->fTied & VLNote::kTiedWithPrev;
|
&& note->fTied & VLNote::kTiedWithPrev;
|
||||||
int pitch = note->fPitch;
|
int pitch = note->fPitch;
|
||||||
if (pitch != VLNote::kNoPitch) {
|
if (pitch != VLNote::kNoPitch) {
|
||||||
[self drawLedgerLinesWithPitch:pitch
|
[self drawLedgerLinesInSection:measure.fPropIdx withPitch:pitch
|
||||||
at:NSMakePoint([self noteXInMeasure:measIdx at:at], kSystemY)];
|
at:NSMakePoint([self noteXInMeasure:measIdx at:at], kSystemY)];
|
||||||
VLMusicElement accidental;
|
VLMusicElement accidental;
|
||||||
NSPoint pos =
|
NSPoint pos =
|
||||||
NSMakePoint([self noteXInMeasure:measIdx at:at],
|
NSMakePoint([self noteXInMeasure:measIdx at:at],
|
||||||
kSystemY+[self noteYWithPitch:pitch
|
kSystemY+[self noteYInSection:measure.fPropIdx
|
||||||
|
withPitch:pitch
|
||||||
accidental:&accidental]);
|
accidental:&accidental]);
|
||||||
VLMusicElement acc = accidental;
|
VLMusicElement acc = accidental;
|
||||||
int step= [self stepWithPitch:pitch];
|
int step= [self stepInSection:measure.fPropIdx
|
||||||
|
withPitch:pitch];
|
||||||
if (acc == accidentals[step])
|
if (acc == accidentals[step])
|
||||||
acc = kMusicNothing; // Don't repeat accidentals
|
acc = kMusicNothing; // Don't repeat accidentals
|
||||||
else if (acc == kMusicNothing)
|
else if (acc == kMusicNothing)
|
||||||
|
@ -326,7 +330,8 @@
|
||||||
VLMusicElement accidental;
|
VLMusicElement accidental;
|
||||||
NSPoint pos =
|
NSPoint pos =
|
||||||
NSMakePoint([self noteXInMeasure:measIdx at:at],
|
NSMakePoint([self noteXInMeasure:measIdx at:at],
|
||||||
kSystemY+[self noteYWithPitch:65
|
kSystemY+[self noteYInSection:measure.fPropIdx
|
||||||
|
withPitch:65
|
||||||
accidental:&accidental]);
|
accidental:&accidental]);
|
||||||
[self drawRest:note->fVisual & VLNote::kNoteHead at: pos];
|
[self drawRest:note->fVisual & VLNote::kNoteHead at: pos];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user