-
Notifications
You must be signed in to change notification settings - Fork 1
/
MixereView.h
396 lines (354 loc) · 9.61 KB
/
MixereView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
// Copyleft 2004 Chris Korda
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or any later version.
// MixereView.h : interface of the CMixereView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MIXEREVIEW_H__21B166D3_F631_4A9B_9142_C0857ED3C3BF__INCLUDED_)
#define AFX_MIXEREVIEW_H__21B166D3_F631_4A9B_9142_C0857ED3C3BF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <afxdlgs.h> // for find/replace dialog
#include "FormListView.h"
#include "Channel.h" // for transport enum
#include "MixerInfo.h"
#include "VolumeBar.h"
#include "TempoBar.h"
#include "MSFadeBar.h"
#include "SnapshotBar.h"
class CMixereDoc;
class CMixerInfo;
class CMultiMix;
class CMultiAutoDlg;
class CSnapshot;
class CMixereView : public CFormListView
{
// Construction
protected: // create from serialization only
CMixereView();
DECLARE_DYNCREATE(CMixereView)
public:
// Constants
enum { // columns: must match column name IDs
COL_NUMBER,
COL_NAME,
COL_TRANSPORT,
COL_MUTE,
COL_VOLUME,
COL_PAN,
COL_PITCH,
COL_POS,
COLUMNS
};
enum { // dialog bars: must match m_DlgBarInfo, and ctor's m_DlgBar init
DLGBAR_VOLUME,
DLGBAR_SNAPSHOT,
DLGBAR_MS_FADE,
DLGBAR_TEMPO,
DLGBARS
};
enum { // custom windows messages
WM_SETDOCTITLE = WM_APP // document title change notification
};
// Attributes
CMixereDoc *GetDocument();
CChannel *GetChan(int Idx) const;
void GetInfo(CMixerInfo& info) const;
bool SetInfo(const CMixerInfo& info);
int GetMuteCount() const;
int GetSoloCount() const;
float GetVolume() const;
void SetVolume(float Volume);
bool IsDlgBarVisible(int BarIdx) const;
BOOL HasToolTips() const;
void SetTitleFont(CFont *Font);
void ApplyColorScheme();
CSnapshot *GetSnapshot() const;
HACCEL GetSnapshotAccel() const;
// Operations
bool LoadAudio(int Pos, LPCSTR Path);
void LoadAudio();
void DropFiles(HDROP hDropInfo);
void SetTransport(int Transport);
void TogglePlay();
void Go();
void SetLoop(int State);
void SetMute(int State);
void SetSolo(int State);
void EndSolo();
void KeepSolo();
void SetDefaults();
void ResetDefaults();
BOOL EnableToolTips(BOOL bEnable);
void ShowDlgBar(int BarIdx, bool Enable);
void ToggleDlgBar(int BarIdx);
void UpdateVolume();
void EditAuto(int AutoIdx);
void EditName();
void TimerHook();
DWORD CreateChanID();
int FindChanByID(DWORD ChanID) const;
// Channel handlers
void OnMute(CChannel *Chan, bool Enable);
void OnSolo(CChannel *Chan, bool Enable);
void OnDropFiles(CChannel *Chan, HDROP hDropInfo);
void OnContextMenu(CChannel *Item, CWnd* pWnd, CPoint point);
const CChanInfo& GetChanDefaults() const;
int GetMSFadeTime() const;
// Snapshot handlers
void OnUpdateSnapshotList();
void OnRestoreSnapshot(int SnapIdx);
// Overridables
virtual float GetMasterVolume();
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMixereView)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnInitialUpdate(); // called first time after construct
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
public:
virtual ~CMixereView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CMixereView)
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg void OnFileProperties();
afx_msg void OnContextCopy();
afx_msg void OnContextCut();
afx_msg void OnContextInsert();
afx_msg void OnContextDelete();
afx_msg void OnTogglePlay();
afx_msg void OnPlay();
afx_msg void OnPause();
afx_msg void OnStop();
afx_msg void OnToggleLoop();
afx_msg void OnToggleMute();
afx_msg void OnToggleSolo();
afx_msg void OnEndSolo();
afx_msg void OnKeepSolo();
afx_msg void OnLoadAudio();
afx_msg void OnEditName();
afx_msg void OnAutoVolume();
afx_msg void OnAutoPan();
afx_msg void OnAutoPitch();
afx_msg void OnAutoPos();
afx_msg void OnSetDefaults();
afx_msg void OnUpdatePlay(CCmdUI* pCmdUI);
afx_msg void OnUpdateEndSolo(CCmdUI* pCmdUI);
afx_msg void OnUpdateSetDefaults(CCmdUI* pCmdUI);
afx_msg void OnMixerVolume();
afx_msg void OnUpdateMixerVolume(CCmdUI* pCmdUI);
afx_msg void OnMixerTempo();
afx_msg void OnUpdateMixerTempo(CCmdUI* pCmdUI);
afx_msg void OnMSFade();
afx_msg void OnUpdateMSFade(CCmdUI* pCmdUI);
afx_msg void OnGo();
afx_msg void OnTakeSnapshot();
afx_msg void OnEditSnapshots();
afx_msg void OnSnapshots();
afx_msg void OnUpdateSnapshots(CCmdUI* pCmdUI);
afx_msg void OnEditFind();
//}}AFX_MSG
afx_msg LRESULT OnSetDocTitle(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnFindReplace(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
protected:
// Nested classes
class CMixerVolumeBar : public CVolumeBar {
public:
CMixerVolumeBar(CMixereView *Mixer);
void OnPosChange();
private:
CMixereView *m_Mixer;
};
class CMixerTempoBar : public CTempoBar {
public:
CMixerTempoBar(CMixereView *Mixer);
void OnPosChange();
private:
CMixereView *m_Mixer;
};
class CMixerMSFadeBar : public CMSFadeBar {
public:
CMixerMSFadeBar(CMixereView *Mixer);
void OnTimeChange();
private:
CMixereView *m_Mixer;
};
class CEditAutoUndoState : public CAutoInfo {
public:
WORD m_ChanIdx;
BYTE m_ChanTransport;
BYTE m_ChanLoop;
int m_ChanPos;
};
// Types
#pragma pack(push, 1) // 1-byte packing alignment
typedef struct {
int m_ChanIdx;
int m_Pos;
BYTE m_Transport;
} TRANSPORT_UNDO_STATE;
typedef struct GO_UNDO_STATE : TRANSPORT_UNDO_STATE {
struct {
double m_Pos;
BYTE m_Transport;
} m_Auto[CChanInfo::AUTOS];
} GO_UNDO_STATE;
#pragma pack(pop) // restore default packing
typedef struct {
int ResID;
int UndoCode;
} DLGBAR_INFO;
// Constants
enum {
START_UCODE = 1000, // so we don't overlap base class undo codes
// start of undo codes: must match m_UndoTitleID array
UCODE_TRANSPORT,
UCODE_GO,
UCODE_LOOP,
UCODE_MUTE,
UCODE_SOLO,
UCODE_END_SOLO,
UCODE_KEEP_SOLO,
UCODE_LOAD_AUDIO,
UCODE_INSERT_AUDIO,
UCODE_SHOW_VOLUME,
UCODE_SHOW_SNAPSHOT,
UCODE_SHOW_MS_FADE,
UCODE_SHOW_TEMPO,
UCODE_SET_DEFAULTS,
UCODE_EDIT_AUTO,
// end of undo codes
END_UCODE,
UNDO_CODE_OFFSET = START_UCODE + 1,
UNDO_CODES = END_UCODE - START_UCODE - 1
};
static const CColumnResizer::COLDEF m_ColumnInfo[COLUMNS];
static const int m_UndoTitleID[UNDO_CODES];
static const DLGBAR_INFO m_DlgBarInfo[DLGBARS];
static const UINT WM_FINDREPLACE;
// Member data
// Components
CMixerVolumeBar m_VolumeBar;
CMixerTempoBar m_TempoBar;
CMixerMSFadeBar m_MSFadeBar;
CSnapshotBar m_SnapshotBar;
CChanInfo m_ChanDefaults;
CFont *m_TitleFont;
CDialogBarEx *m_DlgBar[DLGBARS];
CString m_DlgBarTitle[DLGBARS];
CFrameWnd *m_ChildFrm;
CMultiMix *m_MultiMix;
CMultiAutoDlg *m_MultiAutoDlg;
CSnapshot *m_Snapshot;
// Scalars
BOOL m_HasToolTips;
int m_MuteCount;
int m_SoloCount;
float m_Tempo;
DWORD m_ChanIDs;
// Undo
int m_UndoIdx;
int m_PrevPos;
// Find
CFindReplaceDialog *m_FindDlg;
CString m_FindStr;
bool m_NewFind;
bool m_FindMatchCase;
bool m_FindSearchDown;
// Helpers
bool GetExtension(CString& Ext);
static void AddStringUnique(CStringArray& StrArr, LPCSTR Str);
static void MsgBoxStrList(LPCSTR Msg, const CStringArray& StrArr);
void CreateDlgBars();
void UpdateDlgBarTitles();
bool FindNext();
// Templates
template<class T> void SetUndoChanIdxs(T *uap)
{
int j = 0;
for (int i = 0; i < GetItemCount(); i++) {
if (IsSelOrCur(i))
uap[j++].m_ChanIdx = i;
}
}
// Friends
friend CMixerVolumeBar;
friend CMixerTempoBar;
friend CMixerMSFadeBar;
// Overrides
void OnCreateView();
CFormListItemDlg *OnNewItem();
int MemberSortCompare(const void *elem1, const void *elem2);
void OnPaste(void *Info, int Count, bool Local);
void SaveUndoState(CUndoState& State);
void RestoreUndoState(const CUndoState& State);
CUndoable *FindUndoable(CUndoState::UNDO_KEY Key);
void GetUndoTitle(const CUndoState& State, CString& Title);
// Aliases for undo value members
CUNDOSTATE_VAL( UValBarNum, BYTE, y.c.al) // dialog bar number
CUNDOSTATE_VAL( UValShowBar, BYTE, y.c.ah) // show dialog bar
CUNDOSTATE_VAL( UValAutoIdx, WORD, y.w.lo) // automation index
NOCOPIES(CMixereView);
};
#ifndef _DEBUG // debug version in CMixereView.cpp
inline CMixereDoc* CMixereView::GetDocument()
{ return (CMixereDoc*)m_pDocument; }
#endif
inline CChannel *CMixereView::GetChan(int Idx) const
{
return((CChannel *)m_Item[Idx]);
}
inline float CMixereView::GetVolume() const
{
return(m_VolumeBar.GetVolume());
}
inline int CMixereView::GetMuteCount() const
{
return(m_MuteCount);
}
inline int CMixereView::GetSoloCount() const
{
return(m_SoloCount);
}
inline BOOL CMixereView::HasToolTips() const
{
return(m_HasToolTips);
}
inline const CChanInfo& CMixereView::GetChanDefaults() const
{
return(m_ChanDefaults);
}
inline int CMixereView::GetMSFadeTime() const
{
return(m_MSFadeBar.GetTime());
}
inline DWORD CMixereView::CreateChanID()
{
return(++m_ChanIDs);
}
inline CSnapshot *CMixereView::GetSnapshot() const
{
return(m_Snapshot);
}
inline HACCEL CMixereView::GetSnapshotAccel() const
{
return(m_Snapshot->GetAccel());
}
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MIXEREVIEW_H__21B166D3_F631_4A9B_9142_C0857ED3C3BF__INCLUDED_)