public double[] Jouer(Orchestre or, double fe) { List <double[]> jeux = new List <double[]>(); int attaqueMax = 0; int finMax = 0; if (Anticiper || Complete) { for (int i = 0; i < IndInstruments.Count; i++) { Instrument Ins = or.GetInstrument(IndInstruments.ElementAt(i)); if (Anticiper && Ins.GetEnveloppe().GetNbEchantsAttaque() > attaqueMax) { attaqueMax = Ins.GetEnveloppe().GetNbEchantsAttaque(); } if (Complete && Ins.GetEnveloppe().GetNbEchantsFin() > finMax) { finMax = Ins.GetEnveloppe().GetNbEchantsFin(); } } } for (int i = 0; i < IndInstruments.Count; i++) { Instrument Ins = or.GetInstrument(IndInstruments.ElementAt(i)); jeux.Add(Ins.Jouer(Duree + (double)finMax / fe, note, fe, attaqueMax)); } T0 -= (double)attaqueMax / fe; int lgMax = jeux.Max((f) => f.GetLength(0)); double[] retour = new double[lgMax]; for (int i = 0; i < lgMax; i++) { double somme = 0; for (int j = 0; j < IndInstruments.Count; j++) { if (jeux.ElementAt(j).GetLength(0) > i) { somme += jeux.ElementAt(j)[i]; } } retour[i] = somme * Nuance; } return(retour); }
static void Main(string[] args) { Random r = new Random(); Enveloppe env = new Enveloppe(ProfilEnveloppe.Cos(0, 1, 20000), new ProfilEnveloppe(new List <ProfilEnveloppe>(2) { ProfilEnveloppe.Cos(1, 0.5, 6000), ProfilEnveloppe.Cos(0.5, 1, 9000) }), ProfilEnveloppe.Cos(1, 0, 30000)); ProfilHarmoniques ph = ProfilHarmoniques.Alea(ref r, 3); Instrument flutador = new Instrument(env, ph, 220, 0.8); double[] do_ = flutador.Jouer(4, 0, 44100, 0); string path = "D:/lab/musik/clair.txt"; //DoubleToFile(k, path+".raw"); //VersWav(44100, path + "test.wav", do_); Orchestre orch = new Orchestre(new Instrument[] { flutador }); Musique mc = new Musique(44100, orch, Note.McFromFile(path)); VersWav(44100, path + ".musique.wav", mc.Jouer()); }
public Musique(double fe, Orchestre orchestre, List <Note> notes) { this.fe = fe; this.orchestre = orchestre; this.notes = notes; }