1/*
2 * Copyright 2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _SOUND_FILE_H
6#define _SOUND_FILE_H
7
8
9#include <Entry.h>
10#include <File.h>
11#include <MediaDefs.h>
12
13
14// file formats
15enum {
16	B_UNKNOWN_FILE,
17	B_AIFF_FILE,
18	B_WAVE_FILE,
19	B_UNIX_FILE
20};
21
22
23class BSoundFile  {
24public:
25								BSoundFile();
26								BSoundFile(const entry_ref* ref,
27									uint32 openMode);
28	virtual						~BSoundFile();
29
30			status_t			InitCheck() const;
31
32			status_t			SetTo(const entry_ref* ref, uint32 openMode);
33
34			int32				FileFormat() const;
35			int32				SamplingRate() const;
36			int32				CountChannels() const;
37			int32				SampleSize() const;
38			int32				ByteOrder() const;
39			int32				SampleFormat() const;
40			int32				FrameSize() const;
41			off_t				CountFrames() const;
42
43			bool				IsCompressed() const;
44			int32				CompressionType() const;
45			char*				CompressionName() const;
46
47	virtual	int32				SetFileFormat(int32 format);
48	virtual	int32				SetSamplingRate(int32 fps);
49	virtual	int32				SetChannelCount(int32 samplesPerFrame);
50	virtual	int32				SetSampleSize(int32 bytesPerSample);
51	virtual	int32				SetByteOrder(int32 byteOrder);
52	virtual	int32				SetSampleFormat(int32 format);
53	virtual	int32				SetCompressionType(int32 type);
54	virtual	char*				SetCompressionName(char* name);
55	virtual	bool				SetIsCompressed(bool compressed);
56	virtual	off_t				SetDataLocation(off_t offset);
57	virtual	off_t				SetFrameCount(off_t count);
58
59			size_t				ReadFrames(char* buffer, size_t count);
60			size_t				WriteFrames(char* buffer, size_t count);
61	virtual	off_t				SeekToFrame(off_t index);
62			off_t 				FrameIndex() const;
63			off_t				FramesRemaining() const;
64
65			BFile*				fSoundFile;
66
67private:
68
69	virtual	void				_ReservedSoundFile1();
70	virtual	void				_ReservedSoundFile2();
71	virtual	void				_ReservedSoundFile3();
72
73			void				_init_raw_stats();
74			status_t			_ref_to_file(const entry_ref* ref);
75
76			int32				fFileFormat;
77			int32				fSamplingRate;
78			int32 				fChannelCount;
79			int32				fSampleSize;
80			int32				fByteOrder;
81			int32				fSampleFormat;
82
83			off_t				fByteOffset;
84									// offset to first sample
85
86			off_t				fFrameCount;
87			off_t				fFrameIndex;
88
89			bool				fIsCompressed;
90			int32				fCompressionType;
91			char*				fCompressionName;
92			status_t			fCStatus;
93			BMediaFile*			fMediaFile;
94			BMediaTrack*		fMediaTrack;
95
96			uint32			_reserved[2];
97};
98
99#endif	// _SOUND_FILE_H
100