~ubuntu-branches/ubuntu/trusty/tap-plugins/trusty

« back to all changes in this revision

Viewing changes to tap_echo.c

  • Committer: Bazaar Package Importer
  • Author(s): Eric Hedekar
  • Date: 2009-08-18 18:12:36 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090818181236-r7ajom3tnwboxdoc
Tags: 0.7.1-0ubuntu1
* New Upstream Version (LP: #415680)
* Fixed a number of Lintian warnings
    - updated standards version
    - fixed copyright file issues
    - added watch file
* removed documentation installation (no longer ships with the tarball)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
    along with this program; if not, write to the Free Software
16
16
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
17
 
18
 
    $Id: tap_echo.c,v 1.6 2004/08/05 16:18:44 tszilagyi Exp $
 
18
    $Id: tap_echo.c,v 1.7 2004/12/06 09:32:41 tszilagyi Exp $
19
19
*/
20
20
 
21
21
 
103
103
        if ((ptr = malloc(sizeof(Echo))) != NULL) {
104
104
                ((Echo *)ptr)->sample_rate = SampleRate;
105
105
                ((Echo *)ptr)->run_adding_gain = 1.0f;
 
106
 
 
107
                /* allocate memory for ringbuffers and related dynamic vars */
 
108
                if ((((Echo *)ptr)->ringbuffer_L = 
 
109
                     calloc(MAX_DELAY * ((Echo *)ptr)->sample_rate / 1000,
 
110
                            sizeof(LADSPA_Data))) == NULL)
 
111
                        exit(1);
 
112
                if ((((Echo *)ptr)->ringbuffer_R = 
 
113
                     calloc(MAX_DELAY * ((Echo *)ptr)->sample_rate / 1000,
 
114
                            sizeof(LADSPA_Data))) == NULL)
 
115
                        exit(1);
 
116
                if ((((Echo *)ptr)->buffer_pos_L = calloc(1, sizeof(unsigned long))) == NULL)
 
117
                        exit(1);
 
118
                if ((((Echo *)ptr)->buffer_pos_R = calloc(1, sizeof(unsigned long))) == NULL)
 
119
                        exit(1);
 
120
                
 
121
                *(((Echo *)ptr)->buffer_pos_L) = 0;
 
122
                *(((Echo *)ptr)->buffer_pos_R) = 0;
 
123
                
106
124
                return ptr;
107
125
        }
108
126
        
114
132
void
115
133
activate_Echo(LADSPA_Handle Instance) {
116
134
 
117
 
        Echo * ptr;
118
 
 
119
 
        ptr = (Echo *)Instance;
 
135
        Echo * ptr = (Echo *)Instance;
 
136
        int i;
120
137
        
121
138
        ptr->mpx_out_L = 0;
122
139
        ptr->mpx_out_R = 0;
123
140
        
124
 
        /* allocate memory for ringbuffers and related dynamic vars */
125
 
        if ((ptr->ringbuffer_L = 
126
 
             calloc(MAX_DELAY * ptr->sample_rate / 1000,
127
 
                    sizeof(LADSPA_Data))) == NULL)
128
 
                exit(1);
129
 
        if ((ptr->ringbuffer_R = 
130
 
             calloc(MAX_DELAY * ptr->sample_rate / 1000,
131
 
                    sizeof(LADSPA_Data))) == NULL)
132
 
                exit(1);
133
 
        if ((ptr->buffer_pos_L = calloc(1, sizeof(unsigned long))) == NULL)
134
 
                exit(1);
135
 
        if ((ptr->buffer_pos_R = calloc(1, sizeof(unsigned long))) == NULL)
136
 
                exit(1);
137
 
        
138
141
        *(ptr->buffer_pos_L) = 0;
139
 
        *(ptr->buffer_pos_R) = 0;       
140
 
}
141
 
 
142
 
 
143
 
/* deactivate a plugin instance */
144
 
void
145
 
deactivate_Echo(LADSPA_Handle Instance) {
146
 
 
147
 
        Echo * ptr;
148
 
 
149
 
        ptr = (Echo *)Instance;
150
 
 
151
 
        /* free memory allocated for ringbuffers & co. in activate_Echo() */
152
 
        free(ptr->ringbuffer_L);
153
 
        free(ptr->ringbuffer_R);
154
 
        free(ptr->buffer_pos_L);
155
 
        free(ptr->buffer_pos_R);
 
142
        *(ptr->buffer_pos_R) = 0;
 
143
 
 
144
        for (i = 0; i < MAX_DELAY * ptr->sample_rate / 1000; i++) {
 
145
                ptr->ringbuffer_L[i] = 0.0f;
 
146
                ptr->ringbuffer_R[i] = 0.0f;
 
147
        }
156
148
}
157
149
 
158
150
 
428
420
void 
429
421
cleanup_Echo(LADSPA_Handle Instance) {
430
422
 
 
423
        Echo * ptr = (Echo *)Instance;
 
424
 
 
425
        free(ptr->ringbuffer_L);
 
426
        free(ptr->ringbuffer_R);
 
427
        free(ptr->buffer_pos_L);
 
428
        free(ptr->buffer_pos_R);
 
429
 
431
430
        free(Instance);
432
431
}
433
432
 
584
583
        stereo_descriptor->run = run_Echo;
585
584
        stereo_descriptor->run_adding = run_adding_gain_Echo;
586
585
        stereo_descriptor->set_run_adding_gain = set_run_adding_gain;
587
 
        stereo_descriptor->deactivate = deactivate_Echo;
 
586
        stereo_descriptor->deactivate = NULL;
588
587
        stereo_descriptor->cleanup = cleanup_Echo;
589
588
        
590
589
}