File: reverb.c

package info (click to toggle)
freebirth 0.3.2-9.2
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid, stretch
  • size: 3,632 kB
  • ctags: 640
  • sloc: ansic: 4,724; makefile: 89; sh: 1
file content (102 lines) | stat: -rw-r--r-- 2,793 bytes parent folder | download | duplicates (4)
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
/* Freebirth
 * Copyright (C) 1999 topher lafata <topher@topher.com>,
 *		      Jake Donham <jake@bitmechanic.com>
 *
 * 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 (see COPYING); if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */



#include <stdlib.h>
#include "reverb.h"


sample *reverb_get_buffer(reverb *this)
{
  return this->ap_2->get_buffer(this->ap_2);
}

void reverb_next_buffer(reverb *this)
{
  int i;
  for(i=0; i < NUM_COMBS;i++)
    this->combs[i]->next_buffer(this->combs[i]);
  this->comb_mixer->next_buffer(this->comb_mixer);
  this->ap_1->next_buffer(this->ap_1);
  this->ap_2->next_buffer(this->ap_2);
}

static sample_producer **get_children(reverb *this)
{
  return (sample_producer **)&(this->ap_2);
}

static char **get_header(reverb *this)
{
  static char *header[] = { NULL };
  return header;
}

static char **get_code(reverb *this)
{
  static char *code[] = {
    "$o = $i0;",
    NULL
  };
  return code;
}

static char **get_footer(reverb *this)
{
  static char *footer[] = { NULL };
  return footer;
}

reverb *reverb_new(sample_producer *input)
{
  int i;
  reverb *out = (reverb *)malloc(sizeof(reverb));
  out->get_buffer = reverb_get_buffer;
  out->next_buffer = reverb_next_buffer;
  out->get_children	= get_children;
  out->get_header	= get_header;
  out->get_code		= get_code;
  out->get_footer	= get_footer;
  out->unused		= NULL;

  out->input = input;
  out->combs[0] = delay_new(C1_INIT_D,C1_INIT_F,out->input);
  out->combs[1] = delay_new(C2_INIT_D,C2_INIT_F,out->input);
  out->combs[2] = delay_new(C3_INIT_D,C3_INIT_F,out->input);
  out->combs[3] = delay_new(C4_INIT_D,C4_INIT_F,out->input);
  out->combs[4] = delay_new(C5_INIT_D,C5_INIT_F,out->input);
  out->combs[5] = delay_new(C6_INIT_D,C6_INIT_F,out->input);
  out->combs[6] = NULL;
  
  out->comb_mixer = mixer_new((sample_producer**)out->combs);
  for(i = 0; i < NUM_COMBS;i++)
    mixer_set_amplitude(out->comb_mixer,MIX_MAX_AMP,i);

  out->ap_1 = all_pass_new(AP1_INIT_D,AP1_INIT_F,(sample_producer *)out->comb_mixer);
  out->ap_2 = all_pass_new(AP2_INIT_D,AP2_INIT_F,(sample_producer *)out->ap_1);
  return out;
}

/*
  Local Variables:
  mode: font-lock
  End:
*/