X-Git-Url: http://git.johnwright.org/?p=fmit.git;a=blobdiff_plain;f=libs%2FMusic%2FScoreGenerator.cpp;fp=libs%2FMusic%2FScoreGenerator.cpp;h=2d4d95c2596002fc0890f0abd23b623fad217660;hp=0000000000000000000000000000000000000000;hb=49947d1cd4506f5574b3be62ee90e9f00227d9fd;hpb=82c9faab9421b3d87a0faa84a73f55aaccbbb689 diff --git a/libs/Music/ScoreGenerator.cpp b/libs/Music/ScoreGenerator.cpp new file mode 100644 index 0000000..2d4d95c --- /dev/null +++ b/libs/Music/ScoreGenerator.cpp @@ -0,0 +1,95 @@ +// Copyright 2004 "Gilles Degottex" + +// This file is part of "Music" + +// "Music" is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// "Music" is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +#include "ScoreGenerator.h" + +#include +//#include +//#include +//#include +using namespace std; + +#include +//#include +//using namespace String; +#include + +#include "Music.h" + +namespace Music +{ + +void GenerateScore( vector& buffer, // the score's wav + vector< vector >& score, // the score + double lenght, // lenght of the score in seconds : R+* + int dataBySecond, // number of data by second : ~{11000, 22000, 44100} + double AFreq, // frequency of A : ~440.0 + int minHT, // minimum halftone : Z // TODO <0 + int maxHT, // maximum halftone : Z + int nbNotes, // number of notes in lenght : N* + int nbVoice) // number of voices : N* +{ + static Random rdm; + + int size = int(lenght*dataBySecond); + int nbHT = maxHT-minHT+1; + int note_size = size / nbNotes; + cout << "AFreq=" << AFreq << " dataBySecond=" << dataBySecond << endl; + cout << "nbNotes=" << nbNotes << " lenght=" << lenght << " minHT=" << minHT << " maxHT=" << maxHT << endl; + cout << "size=" << size << " nbHT=" << nbHT << " nbVoice=" << nbVoice << endl; + + cout << "make score ... \t\t" << flush; +// int n=0; + for(int i=0; i hs(nbVoice); + for(size_t v=0; v