r954: Improve icons of the liveaudio and livevideo effects.
[cinelerra_cv.git] / cinelerra / apluginarray.C
blobd1a185cba91bd1f12866d79665a0c4d278b51f23
1 #include "amodule.h"
2 #include "apluginarray.h"
3 #include "atrack.h"
4 #include "cache.h"
5 #include "edl.h"
6 #include "edlsession.h"
7 #include "file.h"
8 #include "mwindow.h"
9 #include "playbackengine.h"
10 #include "pluginserver.h"
11 #include "preferences.h"
12 #include "recordableatracks.h"
13 #include "mainsession.h"
16 #define RING_BUFFERS 2
19 APluginArray::APluginArray()
20  : PluginArray(TRACK_AUDIO)
22         realtime_buffers = 0;
25 APluginArray::~APluginArray()
27         file->stop_audio_thread();
28         for(int i = 0; i < total_tracks(); i++)
29         {
30                 delete modules[i];
31         }
32         delete tracks;
35 void APluginArray::create_buffers()
37         file->start_audio_thread(buffer_size, RING_BUFFERS);
38 //      if(!plugin_server->realtime) realtime_buffers = file->get_audio_buffer();
41 void APluginArray::get_buffers()
43         if(!realtime_buffers) realtime_buffers = file->get_audio_buffer();
46 void APluginArray::create_modules()
48         modules = new Module*[total_tracks()];
49         for(int i = 0; i < total_tracks(); i++)
50         {
51                 modules[i] = new AModule(0, 0, this, tracks->values[i]);
52                 modules[i]->cache = cache;
53                 modules[i]->edl = edl;
54                 modules[i]->create_objects();
55                 modules[i]->render_init();
56         }
59 void APluginArray::process_realtime(int module, int64_t input_position, int64_t len)
61         values[module]->process_buffer(realtime_buffers + module,
62                         input_position, 
63                         len,
64                         edl->session->sample_rate,
65                         0,
66                         PLAY_FORWARD);
69 int APluginArray::process_loop(int module, int64_t &write_length)
71         if(!realtime_buffers) realtime_buffers = file->get_audio_buffer();
72         int result = values[module]->process_loop(&realtime_buffers[module], 
73                 write_length);
74         return result;
78 int APluginArray::write_buffers(int64_t len)
80 //printf("APluginArray::write_buffers 1\n");
81         int result = file->write_audio_buffer(len);
82         realtime_buffers = 0;
84 //      if(!plugin_server->realtime && !done && !result) 
85 //              realtime_buffers = file->get_audio_buffer();
86         return result;
89 int64_t APluginArray::get_bufsize()
91         return edl->session->sample_rate;
95 void APluginArray::get_recordable_tracks()
97         tracks = new RecordableATracks(edl->tracks);
100 int APluginArray::total_tracks()
102         return tracks->total;
105 Track* APluginArray::track_number(int number)
107         return (Track*)tracks->values[number];