@faddys/producer
v1.0.1
Published
Faddy's Music Producer
Downloads
1
Readme
#!/usr/bin/env roll
Faddy's Music Producer
Work of Faddy Michel
In Solidarity with The People of Palestine till Their Whole Land is FREE
Prerequisites
Installation
sudo npm i -g @faddys/producer
Usage
producer [ notation ]
.FaddysProducer
?# if [ ! -d .FaddysProducer ] ; then mkdir .FaddysProducer ; fi
.FaddysProducer/examples/
?# cd .FaddysProducer ; if [ ! -d examples ] ; then mkdir examples ; fi
.FaddysProducer/examples/maqsum.no
?# cd .FaddysProducer/examples ; cat - > maqsum.no
+==
~ 105 4
0/8 dom/01 1/8 tak/04 3/8 tak/07 4/8 dom/12 6/8 tak/06
-==
.FaddysProducer/index.orc
?# cd .FaddysProducer ; if [ ! -f index.orc ] ; then cat - > index.orc ; fi
//+==
sr = 48000
ksmps = 32
nchnls = 6
0dbfs = 1
instr 13, 14, beat
p3 *= 1000
SPath strget p4
strset p5, SPath
iEvent init ( int ( p1 ) % 10 ) + frac ( p1 )
kLoop metro 1/p3
if kLoop == 1 then
schedulek iEvent, 0, 1, p5, p6, p7
endif
endin
instr 3, playback
SPath strget p4
p3 filelen SPath
aLeft, aRight diskin2 SPath
outs aLeft / ( p5 + 1 ), aRight / ( p6 + 1 )
endin
instr 4, recorder
SPath strget p4
SPath1 strcat SPath, ".1.2.wav"
SPath2 strcat SPath, ".3.4.wav"
SPath3 strcat SPath, ".5.6.wav"
aLeft1, aRight1 inch 1, 2
aLeft2, aRight2 inch 3, 4
aLeft3, aRight3 inch 5, 6
fout SPath1, -1, aLeft1, aRight1
fout SPath2, -1, aLeft2, aRight2
fout SPath3, -1, aLeft3, aRight3
endin
//-==
.FaddysProducer/node_modules/@faddys/scenarist
?# cd .FaddysProducer ; if [ ! -d node_modules/@faddys/scenarist ] ; then npm i @faddys/scenarist ; fi
.FaddysProducer/node_modules/@faddys/command
?# cd .FaddysProducer ; if [ ! -d node_modules/@faddys/command ] ; then npm i @faddys/command ; fi
.FaddysProducer/score.mjs
?# cat - > .FaddysProducer/score.mjs
//+==
import Scenarist from '@faddys/scenarist';
import $0 from '@faddys/command';
import { createInterface } from 'node:readline';
await Scenarist ( new class extends Array {
constructor () {
super ();
this .directory = $0 ( 'producer-directory' )
.then ( $ => $ ( Symbol .for ( 'output' ) ) )
.then ( ( [ directory ] ) => directory );
this .argv = process .argv .slice ( 2 );
}
async $_producer ( $ ) {
this .directory = await this .directory;
if ( this .argv .length )
await $ ( ... this .argv );
}
async $score ( $, ... argv ) {
if ( ! argv .length )
throw 'Notation file to score is missing. Usage: score path/to/notation/file';
const notation = await $0 ( 'cat', argv .shift () )
.then ( async $ => ( {
output: await $ ( Symbol .for ( 'output' ) ),
error: await $ ( Symbol .for ( 'error' ) )
} ) );
if ( notation .error .length )
throw 'Could not read the notation file to score. Reason: ' + notation .error .join ( '\n' );
for ( let line of notation .output )
if ( ( line = line .trim () ) .length )
await $ ( ... line .split ( /\s+/ ) );
await $ ( ... argv );
}
async $on () {
const score = await $0 ( 'cat - > .FaddysProducer/index.sco' );
for ( const note of this )
await score ( typeof note === 'object' ? this .note ( note ) : note ) ) .join ( '\n' );
await score ( Symbol .for ( 'end' ) );
await $0 ( 'csound -iadc -odac .FaddysProducer/index.*' );
}
$tempo ( $, ... argv ) {
if ( ! argv .length )
throw 'Tempo VALUE is missing. Usage: tempo VALUE (e.g., tempo 105)';
const input = argv .shift ();
const value = parseFloat ( input );
if ( isNaN ( value ) )
throw 'Tempo VALUE must be numeric. Usage: tempo NUMERIC_VALUE (e.g., tempo 105)';
this .tempo = value;
return $ ( ... argv );
}
$length ( $, ... argv ) {
if ( ! argv .length )
throw 'Bar length VALUE is missing. Usage: length VALUE (e.g., length 4)';
const input = argv .shift ();
const value = parseFloat ( input );
if ( isNaN ( value ) )
throw 'Bar length VALUE must be numeric. Usage: length NUMERIC_VALUE (e.g., length 4)';
this .length = value;
return $ ( ... argv );
}
time = 0;
[ '$|' ] ( $, ... argv ) {
return this .push ( `b ${ ++this .time * this .bar }` ), $ ( ... argv );
}
$$ ( $, label, ... argv ) {
this .label = label;
this [ label ] = [];
this [ '$' + label ] = ( $, ... argv ) => {
this .push ( ... this [ label ] );
return $ ( ... argv );
};
return $ ( ... argv );
}
left = 3;
right =3;
[ '$=' ] ( $, left, right, ... argv ) {
Object .assign ( this, { left, right } );
return $ ( ... argv );
}
#instance = 0
instance () { return ++this .#instance % 10 === 0 ? ++this .#instance : this .#instance }
$_director ( $, ... argv ) {
if ( ! argv .length )
return this .label;
const [ step, divisions ] = argv .shift () .split ( '/' );
const sound = argv .shift ();
const { time } = this;
const note = { step, divisions, sound, time };
this .push ( note );
if ( this .label ?.length )
this [ this .label ] .push ( note );
return $ ( ... argv );
}
note ( { step, divisions, sound, time } ) {
const instance = this .instance ();
return [
'i',
`13.${ instance }`,
`[${ step }/${ divisions }]`,
time === this .time - 1 ? this .time : -this .time,
`"${ this .directory }/equipment/${ sound }.wav"`,
instance,
this .left,
this .right
] .join ( ' ' );
}
record = {}
$o ( $, path ) {
this .push ( `i 4.${ this .record [ path ] = this .instance () } 0 -1 "${ path }"` );
}
} );
//-==
?# $ node .FaddysProducer/score.mjs > .FaddysProducer/index.sco
?# -1 -2 csound -iadc -odac .FaddysProducer/index.*