1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
/* null.c
*
* Copyright (c) 1999 Scott Manley, Barath Raghavan, Jack Moffitt, and Alexander Havng
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 "mixer.h"
/* Null Module.... generates complete silence */
Mod_Ptr mod_null_init(Mod_Ptr out){
Mod_Ptr new;
new=malloc(sizeof(Mod_Struct));
sprintf(new->name,"Null %X",new);
new->Mod_Type=MOD_NULL;
new->volume=1.0;
new->num_ints=0;
new->num_floats=0;
new->num_connections=1;
new->param_i=NULL;
new->param_f=NULL;
new->connections=malloc(sizeof(Mod_Ptr));
new->connections[0]=out;
new->gen_param=NULL;
new->format=out->format;
return new;
}
void mod_null_get(Mod_Ptr set,int *adat){
int i;
for(i=0;i<BUF_SIZE;i++)
adat[i]=0;
}
/* Thru mixer module, again pretty much redundant, sends input to output
after scaling with volume control */
Mod_Ptr mod_thru_init(Mod_Ptr out){
Mod_Ptr new;
new=malloc(sizeof(Mod_Struct));
sprintf(new->name,"Null %X",new);
new->Mod_Type=MOD_THRU;
new->volume=1.0;
new->num_ints=0;
new->num_floats=0;
new->num_connections=2;
new->param_i=NULL;
new->param_f=NULL;
new->connections=malloc(2*sizeof(Mod_Ptr));
new->connections[0]=out;
new->connections[1]=NULL;
new->gen_param=NULL;
new->format=out->format;
return new;
}
void mod_thru_get(Mod_Ptr set,int *adat){
int i;
get_audio(set->connections[1],adat);
for(i=0;i<BUF_SIZE;i++)
adat[i]=adat[i]*set->volume;
}
/* Thru mixer module, two inputs with a cross fader and some parameters
to say what way the cross fade is working */
Mod_Ptr mod_mixer_init(Mod_Ptr out){
Mod_Ptr new;
new=malloc(sizeof(Mod_Struct));
sprintf(new->name,"Null %X",new);
new->Mod_Type=MOD_THRU;
new->volume=1.0;
new->num_ints=0;
new->num_floats=2;
new->num_connections=3;
new->param_i=NULL;
new->param_f=malloc(2*sizeof[float]);
new->param_f[0]=0.5;
new->param_f[1]=0;
new->connections=malloc(3*sizeof(Mod_Ptr));
new->connections[0]=out;
new->connections[1]=NULL;
new->connections[2]=NULL;
new->gen_param=NULL;
new->format=out->format;
return new;
}
void mod_mixer_get(Mod_Ptr set,int *adat){
static int buf[BUF_SIZE];
int i;
get_audio(set->connections[1],adat);
get_audio(set->connections[2],buf);
for(i=0;i<BUF_SIZE;i++)
adat[i]=(adat[i]*set->param_f[0] + buf[i]*(1-set->param_f[0]) ) *set->volume;
}
|