4 * Copyright (C) 2009 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "apluginarray.h"
26 #include "bcsignals.h"
29 #include "edlsession.h"
32 #include "playbackengine.h"
33 #include "pluginserver.h"
34 #include "preferences.h"
35 #include "recordableatracks.h"
37 #include "mainsession.h"
40 #define RING_BUFFERS 2
43 APluginArray::APluginArray()
44 : PluginArray(TRACK_AUDIO)
49 APluginArray::~APluginArray()
51 file->stop_audio_thread();
52 for(int i = 0; i < total_tracks(); i++)
59 void APluginArray::create_buffers()
61 file->start_audio_thread(buffer_size, RING_BUFFERS);
62 // if(!plugin_server->realtime) realtime_buffers = file->get_audio_buffer();
65 void APluginArray::get_buffers()
67 if(!realtime_buffers) realtime_buffers = file->get_audio_buffer();
70 void APluginArray::create_modules()
72 modules = new Module*[total_tracks()];
73 for(int i = 0; i < total_tracks(); i++)
75 modules[i] = new AModule(0, 0, this, tracks->values[i]);
76 modules[i]->cache = cache;
77 modules[i]->edl = edl;
78 modules[i]->create_objects();
79 modules[i]->render_init();
83 void APluginArray::process_realtime(int module, int64_t input_position, int64_t len)
85 int ibfr = module % file->asset->channels;
86 values[module]->process_buffer(realtime_buffers + ibfr,
89 edl->session->sample_rate,
94 int APluginArray::process_loop(int module, int64_t &write_length)
96 if(!realtime_buffers) realtime_buffers = file->get_audio_buffer();
97 int ibfr = module % file->asset->channels;
98 int result = values[module]->process_loop(&realtime_buffers[ibfr],
104 int APluginArray::write_buffers(int64_t len)
106 //printf("APluginArray::write_buffers 1\n");
107 int result = file->write_audio_buffer(len);
108 realtime_buffers = 0;
110 // if(!plugin_server->realtime && !done && !result)
111 // realtime_buffers = file->get_audio_buffer();
115 int64_t APluginArray::get_bufsize()
117 return edl->session->sample_rate;
121 void APluginArray::get_recordable_tracks()
123 tracks = new RecordableATracks(edl->tracks);
126 int APluginArray::total_tracks()
128 return tracks->total;
131 Track* APluginArray::track_number(int number)
133 return (Track*)tracks->values[number];