File: filecommand.h

package info (click to toggle)
mixviews 1.10-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 2,440 kB
  • ctags: 6,314
  • sloc: cpp: 31,647; ansic: 2,100; makefile: 1,782; sh: 17
file content (211 lines) | stat: -rw-r--r-- 5,824 bytes parent folder | download | duplicates (3)
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
// filecommand.h

/******************************************************************************
 *
 *  MiXViews - an X window system based sound & data editor/processor
 *
 *  Copyright (c) 1993, 1994 Regents of the University of California
 *
 *  Author:     Douglas Scott
 *  Date:       December 13, 1994
 *
 *  Permission to use, copy and modify this software and its documentation
 *  for research and/or educational purposes and without fee is hereby granted,
 *  provided that the above copyright notice appear in all copies and that
 *  both that copyright notice and this permission notice appear in
 *  supporting documentation. The author reserves the right to distribute this
 *  software and its documentation.  The University of California and the author
 *  make no representations about the suitability of this software for any 
 *  purpose, and in no event shall University of California be liable for any
 *  damage, loss of data, or profits resulting from its use.
 *  It is provided "as is" without express or implied warranty.
 *
 ******************************************************************************/

// FileCommand is the base class for classes which either create, read, or
// write to files after querying the user for appropriate information.
 
#ifndef FILECOMMAND_H
#ifdef __GNUG__
#pragma interface
#endif
#define FILECOMMAND_H

#include "localdefs.h"
#include "modifier.h"
#include <String.h>

class FileCommand : public Modifier {
	typedef Modifier Super;
public:
	redefined boolean configure(Controller *);
	redefined int apply();
protected:
	FileCommand(const char* filename);
	virtual int doApply() = 0;
	String& fileName() { return theFileName; }
	void setFileName(const char* name) { theFileName = name; }
	Controller* controller() { return theController; }
private:
	String theFileName;
	Controller* theController;
};

class Data;

class FileCreator : public FileCommand {
	typedef FileCommand Super;
	friend class FileCreateRequester;
public:
	Controller* getNewController() { return newController; }
protected:
	FileCreator(const char* filename, int length);
	redefined int doApply();
	virtual Data* newData();
	int dataLength() { return max(4, newLength); }
	boolean setData(Data *);
private:
	Controller* newController;
	Data* theData;
	int newLength;
};

class SoundCreator : public FileCreator {
	typedef FileCreator Super;
	friend class SoundCreateRequester;
public:
	SoundCreator();
	redefined const char* message() { return "Creating new sound..."; }
protected:
	redefined Requester* createRequester();
	redefined void initialize();
private:
	double duration;
	int sampleRate;
	unsigned short channels;
	unsigned short format;
};

class LPCFileCreator : public FileCreator {
	typedef FileCreator Super;
	friend class LPCFileCreateRequester;
public:
	LPCFileCreator();
	redefined const char* message() { return "Creating new LPC file..."; }
protected:
	redefined Requester* createRequester();
	redefined void initialize();
private:
	int nPoles;
	double frameRate;
	int sampleRate;
};

class PvocFileCreator : public FileCreator {
	typedef FileCreator Super;
	friend class PvocFileCreateRequester;
public:
	PvocFileCreator();
	redefined const char* message() { return "Creating new Pvoc file..."; }
protected:
	redefined Requester* createRequester();
	redefined void initialize();
private:
	double frameRate;
	int sampleRate;
	unsigned short nBands;
};

class EnvelopeFileCreator : public FileCreator {
	typedef FileCreator Super;
public:
	EnvelopeFileCreator();
	redefined const char* message() { return "Creating new envelope..."; }
protected:
	redefined Requester* createRequester();
	redefined void initialize();
};

class FileAccessCommand : public FileCommand {
	typedef FileCommand Super;
	friend class FileAccessRequester;
	friend class FileOpenRequester;
public:
	FileAccessCommand(const char* dir);
protected:
	virtual const char* defaultDirectory() { return defaultDir; }
	virtual const char* defaultSuffixes() { return nil; }
private:
	String defaultDir;
};

class FileSaver : public FileAccessCommand {
	typedef FileAccessCommand Super;
	friend class FileSaveRequester;
public:
	FileSaver(const char* dir, Data* data);
	FileSaver(const char* name, const char* dir, Data* data);
	redefined const char* message();
protected:
	redefined Requester* createRequester();
	redefined void initialize();
	redefined int doApply();
protected:
	enum HeaderFormat { Raw = 0x1, WithHeader = 0x2 };
	Data* dataToSave;
	ChoiceValue headerFormat;
private:
	boolean isNewFile;
	boolean forceHeader;
};

class SoundFileSaver : public FileSaver {
	typedef FileSaver Super;
	friend class SoundFileSaveRequester;
public:
	SoundFileSaver(const char* dir, Data* data);
	SoundFileSaver(const char* name, const char* dir, Data* data);
protected:
	redefined Requester* createRequester();
	redefined void initialize();
private:
	ChoiceValue soundHeaderFormat;
};

class LPCFileSaver : public FileSaver {
	typedef FileSaver Super;
public:
	LPCFileSaver(const char* dir, Data* data);
	LPCFileSaver(const char* name, const char* dir, Data* data);
protected:
	redefined void initialize();
};

class DataDumper : public FileSaver {
	typedef FileSaver Super;
	friend class DataDumpRequester;
public:
	DataDumper(const char* dir, Data* data) : FileSaver(dir, data) {}
	redefined const char* message();
protected:
	redefined Requester* createRequester();
	redefined int doApply();
};

class FileOpener : public FileAccessCommand {
	friend class FileOpenRequester;
public:
	FileOpener(const char* dir, const char* title);
	redefined const char* message();
	Controller* getNewController() { return newController; }
protected:
	redefined Requester* createRequester();
	redefined int doApply();
private:
	String theTitle;
	double skipTime;
	double duration;
	Controller* newController;
};

#endif