split resource_thread update into separate audio/video threads, boxblur layout tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / panauto.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 #include "apatchgui.inc"
23 #include "bcpan.h"
24 #include "edl.h"
25 #include "edlsession.h"
26 #include "filexml.h"
27 #include "panauto.h"
28
29 PanAuto::PanAuto(EDL *edl, PanAutos *autos)
30  : Auto(edl, (Autos*)autos)
31 {
32         bzero(values, MAXCHANNELS * sizeof(float));
33         handle_x = handle_y = 0;
34 }
35
36 PanAuto::~PanAuto()
37 {
38 }
39
40 int PanAuto::operator==(Auto &that)
41 {
42         PanAuto *panauto = (PanAuto*)&that;
43
44         return handle_x == panauto->handle_x &&
45                 handle_y == panauto->handle_y;
46 }
47
48 void PanAuto::rechannel()
49 {
50         BC_Pan::stick_to_values(values,
51                 edl->session->audio_channels,
52                 edl->session->achannel_positions,
53                 handle_x,
54                 handle_y,
55                 PAN_RADIUS,
56                 1);
57 }
58
59 void PanAuto::load(FileXML *file)
60 {
61         bzero(values, MAXCHANNELS * sizeof(float));
62         handle_x = file->tag.get_property("HANDLE_X", (int64_t)handle_x);
63         handle_y = file->tag.get_property("HANDLE_Y", (int64_t)handle_y);
64         for(int i = 0; i < edl->session->audio_channels; i++)
65         {
66                 char string[BCTEXTLEN];
67                 sprintf(string, "VALUE%d", i);
68                 values[i] = file->tag.get_property(string, values[i]);
69         }
70 }
71
72 void PanAuto::copy(int64_t start, int64_t end, FileXML *file, int default_auto)
73 {
74         file->tag.set_title("AUTO");
75         if(default_auto)
76                 file->tag.set_property("POSITION", 0);
77         else
78                 file->tag.set_property("POSITION", position - start);
79         file->tag.set_property("HANDLE_X", (int64_t)handle_x);
80         file->tag.set_property("HANDLE_Y", (int64_t)handle_y);
81         for(int i = 0; i < edl->session->audio_channels; i++)
82         {
83                 char  string[BCTEXTLEN];
84                 sprintf(string, "VALUE%d", i);
85                 file->tag.set_property(string, values[i]);
86         }
87         file->append_tag();
88         file->tag.set_title("/AUTO");
89         file->append_tag();
90 }
91
92
93 void PanAuto::copy_from(Auto *that)
94 {
95         Auto::copy_from(that);
96
97         PanAuto *pan_auto = (PanAuto*)that;
98         memcpy(this->values, pan_auto->values, MAXCHANNELS * sizeof(float));
99         this->handle_x = pan_auto->handle_x;
100         this->handle_y = pan_auto->handle_y;
101 }
102
103 void PanAuto::dump()
104 {
105         printf("                handle_x %d\n", handle_x);
106         printf("                handle_y %d\n", handle_y);
107         for(int i = 0; i < edl->session->audio_channels; i++)
108                 printf("                value %d %f\n", i, values[i]);
109 }
110
111