comparison Plugins/Input/console/Track_Emu.h @ 493:c04dff121e1d trunk

[svn] hostile merge, phase 2: reimport based on new plugin code
author nenolod
date Tue, 24 Jan 2006 20:19:01 -0800
parents
children a371216b5c8a
comparison
equal deleted inserted replaced
492:ccb68bad47b2 493:c04dff121e1d
1
2 // Music track emulator that handles fading and lookahead silence detection
3
4 #ifndef TRACK_EMU_H
5 #define TRACK_EMU_H
6
7 #include "Music_Emu.h"
8
9 class Track_Emu {
10 public:
11 // Start track and start fade at fade_time. If detect_silence is true,
12 // continually checks for end-of-track silence of more than around 6
13 // seconds. Keeps pointer to emulator.
14 void start_track( Music_Emu*, int track, long fade_time_msec, bool detect_silence );
15
16 // Seek to new time in track
17 void seek( long msec );
18
19 // Play for 'count' samples and write to output buffer. Returns true when track
20 // has ended.
21 bool play( int count, Music_Emu::sample_t* out );
22
23 private:
24 Music_Emu* emu;
25 Music_Emu::sample_t* buffer;
26 double fade_factor;
27 long emu_time; // number of samples emulator has generated since start of track
28 long out_time; // number of samples played since start of track
29 long silence_time; // number of samples where most recent silence began
30 long fade_time; // number of samples to begin fading at
31 int silence_count; // number of samples of silence to play before using bud
32 int buf_count; // number of samples left in buffer
33 int track;
34 bool detect_silence;
35 bool track_ended;
36 enum { buf_size = 1024 };
37 Music_Emu::sample_t buf [buf_size];
38
39 void end_track();
40 void restart_track();
41 void sync( long time );
42 void fill_buf( bool check_silence );
43 long msec_to_samples( long msec ) const;
44 };
45
46
47 #endif
48