1 /*
2  * Copyright (C) 2002 - David W. Durham
3  *
4  * This file is part of ReZound, an audio editing application.
5  *
6  * ReZound is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published
8  * by the Free Software Foundation; either version 2 of the License,
9  * or (at your option) any later version.
10  *
11  * ReZound is distributed in the hope that it will be useful, but
12  * 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 #include "GenerateActionDialogs.h"
22 #include "../backend/unit_conv.h"
23 
24 #include "../backend/ActionParamMappers.h"
25 
26 // --- Generate Noise -------------------------
27 
28 FXDEFMAP(CGenerateNoiseDialog) CGenerateNoiseDialogMap[]=
29 {
30         //Message_Type                  ID                                                 Message_Handler
31 	FXMAPFUNC(SEL_CHANGED,          CGenerateNoiseDialog::ID_NOISE_COLOR_COMBOBOX,     CGenerateNoiseDialog::onNoiseColorChange),
32 };
33 
FXIMPLEMENT(CGenerateNoiseDialog,CActionParamDialog,CGenerateNoiseDialogMap,ARRAYNUMBER (CGenerateNoiseDialogMap))34 FXIMPLEMENT(CGenerateNoiseDialog,CActionParamDialog,CGenerateNoiseDialogMap,ARRAYNUMBER(CGenerateNoiseDialogMap))
35 
36 CGenerateNoiseDialog::CGenerateNoiseDialog(FXWindow *mainWindow) :
37 	CActionParamDialog(mainWindow)
38 {
39 	vector<string> items;
40 
41 	void *p0=newVertPanel(NULL);
42 		void *p1=newHorzPanel(p0);
43 
44 		addSlider(p1,
45 			N_("Length"),
46 			"s",
47 			new CActionParamMapper_linear(1.0,1,1,10000),
48 			NULL,
49 			false
50 		);
51 
52 		addSlider(p1,
53 			N_("Volume"),
54 			"dBFS",
55 			new CActionParamMapper_dBFS(-6.0),
56 			dB_to_scalar,
57 			false
58 		);
59 
60 		addSlider(p1,
61 			N_("Max Particle Velocity"),
62 			"%",
63 			new CActionParamMapper_linear(50.0,100),
64 			NULL,
65 			false
66 		);
67 
68 	// these need to follow the order in the enum in CGenerateNoiseAction.cpp
69 	items.clear();
70 	items.push_back(_("White (Equal Energy per Frequency)"));
71 	items.push_back(_("Pink (Natural, Equal Energy per Octave; response: f^(-1))"));
72 	items.push_back(_("Brown (as in Brownian Motion; response: f^(-2))"));
73 	items.push_back(_("Black :)"));
74 	//items.push_back("Green");
75 	//items.push_back("Blue");
76 	//items.push_back("Violet");
77 	//items.push_back("Binary");
78 	FXComboTextParamValue *noiseColorComboBox=addComboTextEntry(p0,
79 		N_("Noise Color"),
80 		items,
81 		CActionParamDialog::cpvtAsInteger
82 	);
83 		noiseColorComboBox->setTarget(this);
84 		noiseColorComboBox->setSelector(ID_NOISE_COLOR_COMBOBOX);
85 
86 	onNoiseColorChange(noiseColorComboBox,0,NULL);
87 
88 
89 	// these need to follow the order in the enum in CGenerateNoiseAction.cpp
90 	items.clear();
91 	items.push_back(_("Independent Channels"));
92 	items.push_back(_("Mono"));
93 	items.push_back(_("Inverse Mono"));
94 	//items.push_back("Spatial stereo");
95 	addComboTextEntry(p0,
96 		N_("Stereo Image"),
97 		items,
98 		CActionParamDialog::cpvtAsInteger
99 	);
100 
101 }
102 
onNoiseColorChange(FXObject * sender,FXSelector sel,void * ptr)103 long CGenerateNoiseDialog::onNoiseColorChange(FXObject *sender,FXSelector sel,void *ptr)
104 {
105 	if(((FXComboTextParamValue *)sender)->getIntegerValue()==2)
106 		getSliderParam("Max Particle Velocity")->enable();
107 	else
108 		getSliderParam("Max Particle Velocity")->disable();
109 	return 1;
110 }
111 
112 
113 // --- Generate Tone -------------------------
114 
115 FXDEFMAP(CGenerateToneDialog) CGenerateToneDialogMap[]=
116 {
117         //Message_Type                  ID                                                 Message_Handler
118 	//FXMAPFUNC(SEL_CHANGED,          CGenerateToneDialog::ID_NOISE_COLOR_COMBOBOX,     CGenerateToneDialog::onToneColorChange),
119 };
120 
FXIMPLEMENT(CGenerateToneDialog,CActionParamDialog,CGenerateToneDialogMap,ARRAYNUMBER (CGenerateToneDialogMap))121 FXIMPLEMENT(CGenerateToneDialog,CActionParamDialog,CGenerateToneDialogMap,ARRAYNUMBER(CGenerateToneDialogMap))
122 
123 CGenerateToneDialog::CGenerateToneDialog(FXWindow *mainWindow) :
124 	CActionParamDialog(mainWindow)
125 {
126 #warning make some presets
127 	void *p0=newVertPanel(NULL);
128 		void *p1=newHorzPanel(p0);
129 			addSlider(p1,
130 				N_("Frequency"),
131 				"Hz",
132 				new CActionParamMapper_linear(60.0,440,0,48000),
133 				NULL,
134 				false
135 			);
136 
137 			addSlider(p1,
138 				N_("Length"),
139 				"s",
140 				new CActionParamMapper_linear(1.0,1,1,10000),
141 				NULL,
142 				false
143 			);
144 
145 			addSlider(p1,
146 				N_("Volume"),
147 				"dBFS",
148 				new CActionParamMapper_dBFS(-6.0),
149 				dB_to_scalar,
150 				false
151 			);
152 
153 		vector<string> toneTypes;
154 			// these must match the order that they're defined in CGenerateToneAction::ToneTypes
155 		toneTypes.push_back(_("Sine Wave"));
156 		toneTypes.push_back(_("Square Wave"));
157 		toneTypes.push_back(_("Rising Sawtooth Wave"));
158 		toneTypes.push_back(_("Falling Sawtooth Wave"));
159 		toneTypes.push_back(_("Triangle Wave"));
160 		addComboTextEntry(p0,
161 			N_("Tone Type"),
162 			toneTypes,
163 			CActionParamDialog::cpvtAsInteger
164 		);
165 }
166 
167