| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- /*
- * 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
- *
- */
- /* floatsam version */
- #include <stdio.h>
- #include <stdlib.h>
- #include <structures.h>
- #include <tkglobals.h>
- #include <globcon.h>
- #include <modeno.h>
- #include <arrays.h>
- #include <distort.h>
- #include <cdpmain.h>
- #include <stdlib.h>
- #include <sfsys.h>
- #include <osbind.h>
- static int advance_func(int *current_pos_in_buf,dataptr dz);
- /**************************** DISTORT_OMT ******************************
- *
- * keep 'keep' cycles, omit 'omit' cycles.
- */
- int distort_omt(int *current_pos_in_buf,int inital_phase,dataptr dz)
- {
- int exit_status;
- register int n;
- int i = *current_pos_in_buf;
- float *b = dz->sampbuf[0];
- int keep = dz->iparam[DISTORTO_KEEP] - dz->iparam[DISTORTO_OMIT];
- switch(inital_phase) {
- case(1):
- for(n=0;n<keep;n++) {
- while(b[i]>=0.0) {
- if((exit_status = advance_func(&i,dz))!=CONTINUE)
- return(exit_status);
- }
- while(b[i]<=0.0) {
- if((exit_status = advance_func(&i,dz))!=CONTINUE)
- return(exit_status);
- }
- }
- for(n=0;n<dz->iparam[DISTORTO_OMIT];n++) {
- while(b[i]>=0.0) {
- b[i] = 0;
- if((exit_status = advance_func(&i,dz))!=CONTINUE)
- return(exit_status);
- }
- while(b[i]<=0.0) {
- b[i] = 0.0;
- if((exit_status = advance_func(&i,dz))!=CONTINUE)
- return(exit_status);
- }
- }
- break;
- case(-1):
- for(n=0;n<keep;n++) {
- while(b[i]<=0.0) {
- if((exit_status = advance_func(&i,dz))!=CONTINUE)
- return(exit_status);
- }
- while(b[i]>=0.0) {
- if((exit_status = advance_func(&i,dz))!=CONTINUE)
- return(exit_status);
- }
- }
- for(n=0;n<dz->iparam[DISTORTO_OMIT];n++) {
- while(b[i]<=00) {
- b[i] = 0.0;
- if((exit_status = advance_func(&i,dz))!=CONTINUE)
- return(exit_status);
- }
- while(b[i]>=0.0) {
- b[i] = 0.0;
- if((exit_status = advance_func(&i,dz))!=CONTINUE)
- return(exit_status);
- }
- }
- break;
- }
- *current_pos_in_buf = i;
- return(CONTINUE);
- }
- /******************************** ADVANCE_FUNC ***************************/
- int advance_func(int *current_pos_in_buf,dataptr dz)
- {
- int exit_status;
- if(++(*current_pos_in_buf) >= dz->ssampsread) {
- if(dz->ssampsread > 0) {
- if((exit_status = write_samps(dz->sampbuf[0],dz->ssampsread,dz))<0)
- return(exit_status);
- }
- if(dz->samps_left <= 0)
- return(FINISHED);
- if((exit_status = read_samps(dz->sampbuf[0],dz))<0)
- return(exit_status);
- *current_pos_in_buf = 0;
- }
- return(CONTINUE);
- }
|