Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

apluginarray.C

Go to the documentation of this file.
00001 #include "amodule.h"
00002 #include "apluginarray.h"
00003 #include "atrack.h"
00004 #include "cache.h"
00005 #include "edl.h"
00006 #include "edlsession.h"
00007 #include "file.h"
00008 #include "mwindow.h"
00009 #include "playbackengine.h"
00010 #include "pluginserver.h"
00011 #include "preferences.h"
00012 #include "recordableatracks.h"
00013 #include "mainsession.h"
00014 
00015 
00016 #define RING_BUFFERS 2
00017 
00018 
00019 APluginArray::APluginArray()
00020  : PluginArray(TRACK_AUDIO)
00021 {
00022         realtime_buffers = 0;
00023 }
00024 
00025 APluginArray::~APluginArray()
00026 {
00027         file->stop_audio_thread();
00028         for(int i = 0; i < total_tracks(); i++)
00029         {
00030                 delete modules[i];
00031         }
00032         delete tracks;
00033 }
00034 
00035 void APluginArray::create_buffers()
00036 {
00037         file->start_audio_thread(buffer_size, RING_BUFFERS);
00038 //      if(!plugin_server->realtime) realtime_buffers = file->get_audio_buffer();
00039 }
00040 
00041 void APluginArray::get_buffers()
00042 {
00043         if(!realtime_buffers) realtime_buffers = file->get_audio_buffer();
00044 }
00045 
00046 void APluginArray::create_modules()
00047 {
00048         modules = new Module*[total_tracks()];
00049         for(int i = 0; i < total_tracks(); i++)
00050         {
00051                 modules[i] = new AModule(0, 0, this, tracks->values[i]);
00052                 modules[i]->cache = cache;
00053                 modules[i]->edl = edl;
00054                 modules[i]->create_objects();
00055                 modules[i]->render_init();
00056         }
00057 }
00058 
00059 void APluginArray::process_realtime(int module, int64_t input_position, int64_t len)
00060 {
00061         values[module]->process_buffer(realtime_buffers + module,
00062                         input_position, 
00063                         len,
00064                         edl->session->sample_rate,
00065                         0,
00066                         PLAY_FORWARD);
00067 }
00068 
00069 int APluginArray::process_loop(int module, int64_t &write_length)
00070 {
00071         if(!realtime_buffers) realtime_buffers = file->get_audio_buffer();
00072         int result = values[module]->process_loop(&realtime_buffers[module], 
00073                 write_length);
00074         return result;
00075 }
00076 
00077 
00078 int APluginArray::write_buffers(int64_t len)
00079 {
00080 //printf("APluginArray::write_buffers 1\n");
00081         int result = file->write_audio_buffer(len);
00082         realtime_buffers = 0;
00083 
00084 //      if(!plugin_server->realtime && !done && !result) 
00085 //              realtime_buffers = file->get_audio_buffer();
00086         return result;
00087 }
00088 
00089 int64_t APluginArray::get_bufsize()
00090 {
00091         return edl->session->sample_rate;
00092 }
00093 
00094 
00095 void APluginArray::get_recordable_tracks()
00096 {
00097         tracks = new RecordableATracks(edl->tracks);
00098 }
00099 
00100 int APluginArray::total_tracks()
00101 {
00102         return tracks->total;
00103 }
00104 
00105 Track* APluginArray::track_number(int number)
00106 {
00107         return (Track*)tracks->values[number];
00108 }

Generated on Sun Jan 8 13:38:49 2006 for Cinelerra-svn by  doxygen 1.4.4