home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d03xx
/
d0356.lha
/
AlgoRhythms
/
Source
/
Scales.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-06-05
|
3KB
|
159 lines
/* automusicscales.c */
/* Copyright 1990 Thomas E. Janzen All Rights Reserved */
/*
** FACILITY:
**
** AlgoRhythms music improviser on Commodore (TM) Amiga (TM)
** compiled with Lattice (TM) C 5.05
**
** ABSTRACT:
**
** Algorhythms improvises music over the MIDI serial port.
**
** AUTHORS: Thomas E. Janzen
**
** CREATION DATE: 26-MAR-1990
**
** MODIFICATION HISTORY:
** DATE NAME DESCRIPTION
**--
*/
#include "math.h"
#define CHROMATIC (1)
#define SHORTPENTATONIC (2)
#define HIRA (3)
#define KUMOI (4)
#define KOKIN (5)
#define WHOLETONE (6)
#define DIATONIC (7)
#define HARMONIC (8)
#define HUNGARIAN (9)
#define DIMINISHED (10)
#define LONGPENTATONIC (11)
int InstallScale(const int Select, int scale[]) {
const int hira[12]=
{57,59,60,64,65,69,71,72,76,77,81,83}; /*hira joshi koto*/
const int kumoi[12]=
{57,58,62,64,65,69,70,74,76,77,81,83};/*kumoi joshi koto*/
const int kokin[11]=
{59,62,64,65,69,71,74,76,77,81,83}; /*kokin joshi koto*/
const int chromatic[12]={0,1,2,3,4,5,6,7,8,9,10,11}; /*chromatic*/
const int lucy[13]={48,50,53,55,58,60,62,65,67,70,72,74,77};
const int Diatonic[7]={0,2,4,5,7,9,11};
const int HarmMinor[7]={0,2,3,5,7,8,11};
const int HungMinor[7]={0,2,3,6,7,8,11};
const int diminished[8]={0,2,3,5,6,8,9,11};
const int pentatonic[5]={0,2,4,7,9};
const int wholetone[6]={0,2,4,6,8,10}; /*whole tone scale*/
register int i;
register int oct;
switch(Select) {
case CHROMATIC: /*chromatic*/
for (oct=0; oct<7; oct++) {
for (i=0; i<7; i++) {
scale[i+(oct*12)]=
chromatic[i]+((oct+2)*12);
}
}
return 84;
break;
case SHORTPENTATONIC: /*Pentatonic (Lucy) */
for (i=0; i<13; i++) {
scale[i] = lucy[i];
}
return 13;
break;
case HIRA:
for (i=0; i<12; i++) {
scale[i]=hira[i];
}
return 12;
break;
case KUMOI:
for (i=0; i<12; i++) {
scale[i]=kumoi[i];
}
return 12;
break;
case KOKIN:
for (i=0; i<11; i++) {
scale[i]=kokin[i];
}
return 11;
break;
case WHOLETONE: /*whole tone*/
for (oct=0; oct<7; oct++) {
for (i=0; i<7; i++) {
scale[i+(oct*6)]=
wholetone[i]+((oct+2)*12);
}
}
return 42;
break;
case DIATONIC: /*diatonic*/
for (oct=0; oct<7; oct++) {
for (i=0; i<7; i++) {
scale[i+(oct*7)]=
Diatonic[i]+((oct+2)*12);
}
}
return 49;
break;
case HARMONIC: /* harmonic minor */
for (oct=0; oct<7; oct++) {
for (i=0; i<7; i++) {
scale[i+(oct*7)]=
HarmMinor[i]+((oct+2)*12);
}
}
return 49;
break;
case HUNGARIAN: /* hungarian minor */
for (oct=0; oct<7; oct++) {
for (i=0; i<7; i++) {
scale[i+(oct*7)]=
HungMinor[i]+((oct+2)*12);
}
}
return 49;
break;
case DIMINISHED: /*diminished scale */
for (oct=0; oct<7; oct++) {
for(i=0; i<8; i++) {
scale[i+(oct*8)]=
diminished[i]+((oct+2)*12);
}
}
return 56;
break;
case LONGPENTATONIC: /*long pentatonic scale */
for (oct=0; oct<7; oct++) {
for(i=0; i<5; i++) {
scale[i+(oct*5)]=
pentatonic[i]+((oct+2)*12);
}
}
return 35;
break;
default:
for (i=0; i<13; i++) {
scale[i] = lucy[i];
}
return 13;
break;
}
}
void TransposeScale(const int transpose, int *scale, const int range) {
register int i;
if (abs(transpose)<12) {
for(i=0;i<range;i++) {
scale[i]=scale[i]+transpose;
}
}
}