comparison src/console/Track_Emu.h @ 12:3da1b8942b8b trunk

[svn] - remove src/Input src/Output src/Effect src/General src/Visualization src/Container
author nenolod
date Mon, 18 Sep 2006 03:14:20 -0700
parents src/Input/console/Track_Emu.h@13389e613d67
children
comparison
equal deleted inserted replaced
11:cff1d04026ae 12:3da1b8942b8b
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 long tell() const;
20
21 // Play for 'count' samples and write to output buffer. Returns true when track
22 // has ended.
23 bool play( int count, Music_Emu::sample_t* out );
24
25 private:
26 Music_Emu* emu;
27 Music_Emu::sample_t* buffer;
28 double fade_factor;
29 long emu_time; // number of samples emulator has generated since start of track
30 long out_time; // number of samples played since start of track
31 long silence_time; // number of samples where most recent silence began
32 long fade_time; // number of samples to begin fading at
33 int silence_count; // number of samples of silence to play before using bud
34 int buf_count; // number of samples left in buffer
35 int track;
36 bool detect_silence;
37 bool track_ended;
38 enum { buf_size = 1024 };
39 Music_Emu::sample_t buf [buf_size];
40
41 void end_track();
42 void restart_track();
43 void sync( long time );
44 void fill_buf( bool check_silence );
45 long msec_to_samples( long msec ) const;
46 };
47
48
49 #endif
50