initial commit
[goodguy/history.git] / cinelerra-5.0 / cinelerra / arender.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2009 Adam Williams <broadcast at earthling dot net>
5  * 
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.
10  * 
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.
15  * 
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
19  * 
20  */
21
22 #ifndef ARENDER_H
23 #define ARENDER_H
24
25 #include "atrack.inc"
26 #include "commonrender.h"
27 #include "maxchannels.h"
28 #include "samples.inc"
29
30 class ARender : public CommonRender
31 {
32 public:
33         ARender(RenderEngine *renderengine);
34         ~ARender();
35
36         void arm_command();
37         void allocate_buffers(int samples);
38 // Used by realtime rendering
39         void init_output_buffers();
40         void interrupt_playback();
41         VirtualConsole* new_vconsole_object();
42         int get_total_tracks();
43         Module* new_module(Track *track);
44
45 // set up and start thread
46         int arm_playback(int64_t current_position,
47                                 int64_t input_length, 
48                                 int64_t module_render_fragment, 
49                                 int64_t playback_buffer, 
50                                 int64_t output_length);
51         int wait_for_startup();
52
53 // process a buffer
54 // renders into buffer_out argument when no audio device
55 // handles playback autos
56         int process_buffer(Samples **buffer_out, 
57                 int64_t input_len,
58                 int64_t input_position);
59 // renders to a device when there's a device
60         int process_buffer(int64_t input_len, int64_t input_position);
61
62         void run();
63
64         void send_last_buffer();
65         int stop_audio(int wait);
66
67 // Calculate number of samples in each meter fragment and how many
68 // meter fragments to buffer.
69         int calculate_history_size();
70 // Get subscript of history entry corresponding to sample
71         int get_history_number(int64_t *table, int64_t position);
72
73         int64_t tounits(double position, int round);
74         double fromunits(int64_t position);
75
76 // pointers to output buffers for VirtualConsole
77         Samples *audio_out[MAXCHANNELS];
78 // allocated memory for output
79         Samples *buffer[MAXCHANNELS];
80 // allocated buffer sizes for nested EDL rendering
81         int buffer_allocated[MAXCHANNELS];
82 // information for meters
83         int get_next_peak(int current_peak);
84         int init_meters();
85 // samples to use for one meter update.  Must be multiple of fragment_len
86         int64_t meter_render_fragment;
87 // Level history of output buffers
88         double *level_history[MAXCHANNELS];
89 // sample position of each level
90         int64_t *level_samples;
91 // total entries in level_history
92         int total_peaks;
93 // Next level to store value in
94         int current_level[MAXCHANNELS];
95 // Make VirtualAConsole block before the first buffer until video is ready
96         int first_buffer;
97 };
98
99
100
101 #endif