r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / menuaeffects.C
blob73cc7b349f5fb52bbb82b353d371924d1fd4cb47
1 #include "apluginarray.h"
2 #include "assets.h"
3 #include "defaults.h"
4 #include "edl.h"
5 #include "edlsession.h"
6 #include "file.h"
7 #include "mainmenu.h"
8 #include "mainsession.h"
9 #include "mwindow.h"
10 #include "mwindowgui.h"
11 #include "menuaeffects.h"
12 #include "patchbay.h"
13 #include "tracks.h"
15 // ============================================= audio effects
17 MenuAEffects::MenuAEffects(MWindow *mwindow)
18  : MenuEffects(mwindow)
20         thread = new MenuAEffectThread(mwindow);
23 MenuAEffects::~MenuAEffects()
25         delete thread;
28 MenuAEffectThread::MenuAEffectThread(MWindow *mwindow)
29  : MenuEffectThread(mwindow)
33 MenuAEffectThread::~MenuAEffectThread()
37 int MenuAEffectThread::get_recordable_tracks(Asset *asset)
39         asset->channels = mwindow->edl->tracks->recordable_audio_tracks();
40         return asset->channels;
44 int MenuAEffectThread::get_derived_attributes(Asset *asset, Defaults *defaults)
46         char string[1024];
47         File file;
48         defaults->get("AEFFECTPATH", asset->path);
49         sprintf(string, "WAV");
50         defaults->get("AEFFECTFORMAT", string);
51         if(!file.supports_audio(mwindow->plugindb, string)) sprintf(string, WAV_NAME);
52         asset->format = file.strtoformat(mwindow->plugindb, string);
53 //printf("MenuAEffectThread::get_derived_attributes %s\n", string);
54         asset->sample_rate = mwindow->edl->session->sample_rate;
55         asset->bits = defaults->get("AEFFECTBITS", 16);
56         dither = defaults->get("AEFFECTDITHER", 0);
57         asset->signed_ = defaults->get("AEFFECTSIGNED", 1);
58         asset->byte_order = defaults->get("AEFFECTBYTEORDER", 1);
59         asset->audio_data = 1;
65         asset->load_defaults(defaults);
66         defaults->get("EFFECT_AUDIO_CODEC", asset->acodec);
67         return 0;
70 int MenuAEffectThread::save_derived_attributes(Asset *asset, Defaults *defaults)
72         File file;
73         defaults->update("AEFFECTPATH", asset->path);
74         defaults->update("AEFFECTFORMAT", file.formattostr(mwindow->plugindb, asset->format));
75 //printf("MenuAEffectThread::save_derived_attributes %s\n", file.formattostr(mwindow->plugindb, asset->format));
76         defaults->update("AEFFECTBITS", asset->bits);
77         defaults->update("AEFFECTDITHER", dither);
78         defaults->update("AEFFECTSIGNED", asset->signed_);
79         defaults->update("AEFFECTBYTEORDER", asset->byte_order);
81         asset->save_defaults(defaults);
82         defaults->update("EFFECT_AUDIO_CODEC", asset->acodec);
83         return 0;
87 PluginArray* MenuAEffectThread::create_plugin_array()
89         return new APluginArray();
92 int64_t MenuAEffectThread::to_units(double position, int round)
94         if(round)
95                 return Units::round(position * mwindow->edl->session->sample_rate);
96         else
97                 return (int64_t)(position * mwindow->edl->session->sample_rate);
98                 
99         return 0;
102 int MenuAEffectThread::fix_menu(char *title)
104         mwindow->gui->mainmenu->add_aeffect(title); 
109 MenuAEffectItem::MenuAEffectItem(MenuAEffects *menueffect, char *string)
110  : MenuEffectItem(menueffect, string)