/* * Copyright (c) 1983-2013 Trevor Wishart and Composers Desktop Project Ltd * http://www.trevorwishart.co.uk * http://www.composersdesktop.com * This file is part of the CDP System. The CDP System 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. The CDP System 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 the CDP System; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include void do_shuffle(int, int); /**************************** M_REPOS ********************************/ int m_repos(int j) { int n, m, k=cnt, OK, is_set = 0; int zib = -ifactor, zab = ifactor; for(n=0;nj && !is_set) { zib++; zab++; is_set = 1; } for(m=zib;m=cnt) break; if(flteq(fmod(number[j],12.0),fmod(number[n+m],12.0))) { OK = 0; break; } } if(OK) { do_shuffle(n,j); if(j>n) return(1); /* list shuffled forward */ return(0); /* list not shuffled forward */ } } return(-1); } /**************************** F_REPOS ********************************/ int f_repos(int j) { int n, m, k=cnt-ifactor, OK, is_set = 0; double interval; int zib = -ifactor, zab = ifactor; for(n=0;nj && !is_set) { zib++; zab++; is_set = 1; } for(m=zib;m=cnt) break; interval = log(number[j]/number[n+m])/LOG_2_TO_BASE_E; interval = fmod(fabs(interval),1.0); if(intervalONEMIN) { OK = 0; break; } } if(OK) { do_shuffle(n,j); if(j>n) return(1); /* list shuffled forward */ return(0); /* list not shuffled forward */ } } return(-1); } /**************************** DO_SHUFFLE ******************************/ void do_shuffle(int n,int j) { int m; double keep = number[j]; if(j > n) { for(m=j;m>n;m--) number[m] = number[m-1]; } else { for(m=j;m