This is NoteRepository.m in view mode; [Download] [Up]
#import "NoteRepository.h"
static id _instance = nil;
typedef struct nnS{
char *n1;
char *n2;
}nnT;
static nnT nl[47] ={
{"e",NULL},
{"f","#e"},
{"#f","bg"},
{"g",NULL},
{"#g","ba"},
{"a", NULL},
{"#a","b"},
{"h","bc1"},
{"c1",NULL},
{"#c1","bd1"},
{"d1",NULL},
{"#d1","be1"},
{"e1",NULL},
{"f1","#e1"},
{"#f1","bg1"},
{"g1",NULL},
{"#g1","ba1"},
{"a1",NULL},
{"#a1","b1"},
{"h1","bc1"},
{"c2",NULL},
{"#c2","bd2"},
{"d2",NULL},
{"#d2","be2"},
{"e2",NULL},
{"f2","#e2"},
{"#f2","bg2"},
{"g2",NULL},
{"#g2","ba2"},
{"a2",NULL},
{"#a2","b2"},
{"h2","bc2"},
{"c3",NULL},
{"#c3","bd3"},
{"d3",NULL},
{"#d3","be3"},
{"e3",NULL},
{"f3","#e3"},
{"#f3","bg3"},
{"g3",NULL},
{"#g3","ba3"},
{"a3",NULL},
{"#a3","b3"},
{"h3","bc3"},
{"c4",NULL},
{"#c4","bd4"},
{"d4",NULL},
};
static notationT not[47*2] ={
{0, VORZ_},{-1,-1},
{1, VORZ_},{0, VORZK},
{1, VORZK},{2, VORZB},
{2, VORZ_},{-1,-1},
{2, VORZK},{3, VORZB},
{3, VORZ_},{-1,-1},
{3, VORZK},{4, VORZB},
{4, VORZ_},{5, VORZB},
{5, VORZ_},{-1,-1},
{5, VORZK},{6, VORZB},
{6, VORZ_},{-1,-1},
{6, VORZK},{7, VORZB},
{7, VORZ_},{-1,-1},
{8, VORZ_},{7, VORZK},
{8, VORZK},{9, VORZB},
{9, VORZ_},{-1,-1},
{9, VORZK},{10, VORZB},
{10, VORZ_},{-1,-1},
{10, VORZK},{11, VORZB},
{11, VORZ_},{12, VORZB},
{12, VORZ_},{-1,-1},
{12, VORZK},{13, VORZB},
{13, VORZ_},{-1,-1},
{13, VORZK},{14, VORZB},
{14, VORZ_},{-1,-1},
{15, VORZ_},{14, VORZK},
{15, VORZK},{16, VORZB},
{16, VORZ_},{-1,-1},
{16, VORZK},{17, VORZB},
{17, VORZ_},{-1,-1},
{17, VORZK},{18, VORZB},
{18, VORZ_},{19, VORZB},
{19, VORZ_},{-1,-1},
{19, VORZK},{20, VORZB},
{20, VORZ_},{-1,-1},
{20, VORZK},{21, VORZB},
{21, VORZ_},{-1,-1},
{22, VORZ_},{21, VORZK},
{22, VORZK},{23, VORZB},
{23, VORZ_},{-1,-1},
{23, VORZK},{24, VORZB},
{24, VORZ_},{-1,-1},
{24, VORZK},{25, VORZB},
{25, VORZ_},{26, VORZB},
{26, VORZ_},{-1,-1},
{26, VORZK},{27, VORZB},
{27, VORZ_},{-1,-1},
};
@implementation NoteRepository
+ instance;
{
if(!(_instance)){
_instance= [[self alloc]init];
}
return _instance;
}
- init;
{
int i;
[super init];
// Notenvorrat aufbauen;
for(i=0;i<47;i++){
note[i]=[[Note alloc]init];
[note[i] setName1:nl[i].n1 name2:nl[i].n2];
[note[i] setNot1:¬[2*i] not2:¬[2*i+1]];
[note[i] setNr:i+1];
}
return self;
}
- (Note *)noteByNr:(int)value;
{
if(0<value && value<=47){
[note[value-1] setB:NO];
return note[value-1];
}
return nil;
}
- (Note *)noteByLoc:(locationT *)value;
{
int i,j;
Note *myNote;
locationT *lP;
for(i=0;i<47;i++){
myNote = note[i];
for(j=0;j<5;j++){
lP = [myNote loc:j];
if(lP->string == value->string &&
lP->fret == value->fret &&
lP->string != -1){
[myNote setB:NO];
return myNote;
}
}
}
return nil;
}
- (Note *)noteByNot:(notationT *)value;
{
int i;
Note *myNote;
notationT *nP;
for(i=0;i<47;i++){
myNote = note[i];
nP = [myNote not1];
if(nP->nr == value->nr && nP->vorz == value->vorz){
[myNote setB:NO];
return myNote;
}
nP = [myNote not2];
if(nP->nr == value->nr && nP->vorz == value->vorz){
[myNote setB:YES];
return myNote;
}
}
return nil;
}
- (Note *)noteByNam:(char *)value;
{
int i;
char *n;
Note *myNote;
if(value){
for(i=0;i<47;i++){
myNote = note[i];
if(n=[myNote name1]){
if(!strcmp(n,value)){
[myNote setB:NO];
return myNote;
}
}
if(n=[myNote name2]){
if(!strcmp(n,value)){
[myNote setB:YES];
return myNote;
}
}
}
}
return nil;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.