Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[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  * Copyright (C) 2003-2016 Cinelerra CV contributors
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22
23 #include "apatchgui.inc"
24 #include "bcpan.h"
25 #include "edl.h"
26 #include "edlsession.h"
27 #include "filexml.h"
28 #include "panauto.h"
29
30 PanAuto::PanAuto(EDL *edl, PanAutos *autos)
31  : Auto(edl, (Autos*)autos)
32 {
33         bzero(values, MAXCHANNELS * sizeof(float));
34         handle_x = handle_y = 0;
35 }
36
37 PanAuto::~PanAuto()
38 {
39 }
40
41 int PanAuto::operator==(Auto &that)
42 {
43         PanAuto *panauto = (PanAuto*)&that;
44
45         return handle_x == panauto->handle_x &&
46                 handle_y == panauto->handle_y;
47 }
48
49 void PanAuto::rechannel()
50 {
51         BC_Pan::stick_to_values(values,
52                 edl->session->audio_channels,
53                 edl->session->achannel_positions,
54                 handle_x,
55                 handle_y,
56                 PAN_RADIUS,
57                 1);
58 }
59
60 void PanAuto::load(FileXML *file)
61 {
62         bzero(values, MAXCHANNELS * sizeof(float));
63         handle_x = file->tag.get_property("HANDLE_X", (int64_t)handle_x);
64         handle_y = file->tag.get_property("HANDLE_Y", (int64_t)handle_y);
65         for(int i = 0; i < edl->session->audio_channels; i++)
66         {
67                 char string[BCTEXTLEN];
68                 sprintf(string, "VALUE%d", i);
69                 values[i] = file->tag.get_property(string, values[i]);
70         }
71 }
72
73 void PanAuto::copy(int64_t start, int64_t end, FileXML *file, int default_auto)
74 {
75         file->tag.set_title("AUTO");
76         if(default_auto)
77                 file->tag.set_property("POSITION", 0);
78         else
79                 file->tag.set_property("POSITION", position - start);
80         file->tag.set_property("HANDLE_X", (int64_t)handle_x);
81         file->tag.set_property("HANDLE_Y", (int64_t)handle_y);
82         for(int i = 0; i < edl->session->audio_channels; i++)
83         {
84                 char  string[BCTEXTLEN];
85                 sprintf(string, "VALUE%d", i);
86                 file->tag.set_property(string, values[i]);
87         }
88         file->append_tag();
89         file->tag.set_title("/AUTO");
90         file->append_tag();
91 }
92
93
94 void PanAuto::copy_from(Auto *that)
95 {
96         Auto::copy_from(that);
97
98         PanAuto *pan_auto = (PanAuto*)that;
99         memcpy(this->values, pan_auto->values, MAXCHANNELS * sizeof(float));
100         this->handle_x = pan_auto->handle_x;
101         this->handle_y = pan_auto->handle_y;
102 }
103
104 void PanAuto::dump()
105 {
106         printf("                handle_x %d\n", handle_x);
107         printf("                handle_y %d\n", handle_y);
108         for(int i = 0; i < edl->session->audio_channels; i++)
109                 printf("                value %d %f\n", i, values[i]);
110 }
111
112