xref: /haiku/headers/os/media/SoundFile.h (revision 51978af14a173e7fae0563b562be5603bc652aeb)
1 /******************************************************************************
2 
3 	File: SoundFile.h
4 
5 	Description:	Interface for a format-insensitive sound file object.
6 
7 	Copyright 1995-97, Be Incorporated
8 
9 ******************************************************************************/
10 
11 
12 #ifndef _SOUND_FILE_H
13 #define _SOUND_FILE_H
14 
15 #ifndef _BE_BUILD_H
16 #include <BeBuild.h>
17 #endif
18 #include <MediaDefs.h>
19 #include <Entry.h>
20 #include <File.h>
21 
22 enum  /* sound_format*/
23 { B_UNKNOWN_FILE,
24   B_AIFF_FILE,
25   B_WAVE_FILE,
26   B_UNIX_FILE };
27 
28 class BSoundFile  {
29 
30 public:
31 					BSoundFile();
32 					BSoundFile(const entry_ref *ref,
33 							   uint32 open_mode);
34 	virtual			~BSoundFile();
35 
36 	status_t		InitCheck() const;
37 
38 	status_t		SetTo(const entry_ref *ref, uint32 open_mode);
39 
40 	int32			FileFormat() const;
41 	int32			SamplingRate() const;
42 	int32			CountChannels() const;
43 	int32			SampleSize() const;
44 	int32			ByteOrder() const;
45 	int32			SampleFormat() const;
46 	int32			FrameSize() const;
47 	off_t			CountFrames() const;
48 
49 	bool			IsCompressed() const;
50 	int32			CompressionType() const;
51 	char	 		*CompressionName() const;
52 
53 	virtual int32 	SetFileFormat(int32 format);
54 	virtual int32	SetSamplingRate(int32 fps);
55 	virtual int32	SetChannelCount(int32 spf);
56 	virtual int32	SetSampleSize(int32 bps);
57 	virtual int32	SetByteOrder(int32 bord);
58 	virtual int32	SetSampleFormat(int32 fmt);
59 	virtual int32	SetCompressionType(int32 type);
60 	virtual char   	*SetCompressionName(char *name);
61 	virtual bool	SetIsCompressed(bool tf);
62 	virtual	off_t	SetDataLocation(off_t offset);
63 	virtual off_t	SetFrameCount(off_t count);
64 
65 	size_t			ReadFrames(char *buf,  size_t count);
66 	size_t			WriteFrames(char *buf, size_t count);
67 	virtual off_t	SeekToFrame(off_t n);
68 	off_t 			FrameIndex() const;
69 	off_t			FramesRemaining() const;
70 
71 	BFile			*fSoundFile;
72 
73 private:
74 
75 virtual	void		_ReservedSoundFile1();
76 virtual	void		_ReservedSoundFile2();
77 virtual	void		_ReservedSoundFile3();
78 
79 	int32			fFileFormat;
80 	int32			fSamplingRate;
81 	int32 			fChannelCount;
82 	int32			fSampleSize;
83 	int32			fByteOrder;
84 	int32			fSampleFormat;
85 
86 	off_t			fByteOffset;	/* offset to first sample */
87 
88 	off_t			fFrameCount;
89 	off_t			fFrameIndex;
90 
91 	bool			fIsCompressed;
92 	int32			fCompressionType;
93 	char			*fCompressionName;
94 	status_t		fCStatus;
95 	void _init_raw_stats();
96 	status_t _ref_to_file(const entry_ref *ref);
97 	uint32			_reserved[4];
98 };
99 
100 
101 #endif			/* #ifndef _SOUND_FILE_H*/
102