r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / apluginarray.C
blob95e2efb941aaf5de3793bc2bc99e6e968aa737be
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"
15 APluginArray::APluginArray()
16  : PluginArray()
18         realtime_buffers = 0;
21 APluginArray::~APluginArray()
23         file->stop_audio_thread();
24         for(int i = 0; i < total_tracks(); i++)
25         {
26                 delete modules[i];
27         }
28         delete tracks;
31 void APluginArray::create_buffers()
33         file->start_audio_thread(buffer_size, RING_BUFFERS);
34 //      if(!plugin_server->realtime) realtime_buffers = file->get_audio_buffer();
37 void APluginArray::create_modules()
39         modules = new Module*[total_tracks()];
40         for(int i = 0; i < total_tracks(); i++)
41         {
42                 modules[i] = new AModule(0, 0, this, tracks->values[i]);
43                 modules[i]->cache = cache;
44                 modules[i]->edl = edl;
45                 modules[i]->create_objects();
46                 modules[i]->render_init();
47         }
50 void APluginArray::load_module(int module, int64_t input_position, int64_t len)
52         if(module == 0) realtime_buffers = file->get_audio_buffer();
53 //printf("APluginArray::load_module 1 %d %d %p %p\n", module, len, realtime_buffers, realtime_buffers[module]);
54         ((AModule*)modules[module])->render(realtime_buffers[module], 
55                 len, 
56                 input_position,
57                 PLAY_FORWARD);
60 void APluginArray::process_realtime(int module, int64_t input_position, int64_t len)
62 //printf("APluginArray::process_realtime 1 %d %p %p\n", len, realtime_buffers, realtime_buffers[0]);
63         values[module]->process_realtime(realtime_buffers + module, 
64                         realtime_buffers + module,
65                         input_position, 
66                         len,
67                         0);
70 int APluginArray::process_loop(int module, int64_t &write_length)
72 //printf("APluginArray::process_loop 1\n");
73         if(!realtime_buffers) realtime_buffers = file->get_audio_buffer();
74 //printf("APluginArray::process_loop 2\n");
75         int result = values[module]->process_loop(&realtime_buffers[module], 
76                 write_length);
77 //printf("APluginArray::process_loop 3\n");
78         return result;
82 int APluginArray::write_buffers(int64_t len)
84 //printf("APluginArray::write_buffers 1\n");
85         int result = file->write_audio_buffer(len);
86         realtime_buffers = 0;
88 //      if(!plugin_server->realtime && !done && !result) 
89 //              realtime_buffers = file->get_audio_buffer();
90         return result;
93 int64_t APluginArray::get_bufsize()
95         return mwindow->edl->session->sample_rate;
99 void APluginArray::get_recordable_tracks()
101         tracks = new RecordableATracks(mwindow->edl->tracks);
104 int APluginArray::total_tracks()
106         return tracks->total;
109 Track* APluginArray::track_number(int number)
111         return (Track*)tracks->values[number];