@@ -20,6 +20,39 @@ namespace audio
20
20
21
21
class ChipTuneEngineParser
22
22
{
23
+ void clear ()
24
+ {
25
+ m_instruments_basic.clear ();
26
+ m_instruments_ring_mod.clear ();
27
+ m_instruments_conv.clear ();
28
+ m_instruments_weight_avg.clear ();
29
+ m_instruments_lib.clear ();
30
+ m_envelopes.clear ();
31
+ m_filter_args.clear ();
32
+ m_waveform_params.clear ();
33
+
34
+
35
+ m_time_step_ms.clear ();
36
+ m_curr_time_step_ms = 100 ;
37
+
38
+ m_volume.clear ();
39
+ m_curr_volume = 1 .f ;
40
+
41
+ m_labels.clear (); // note_idx -> Label (label, id)
42
+ m_gotos.clear (); // note_idx -> Goto (from_label, to_label, count)
43
+ m_al_fine = false ;
44
+ m_al_coda = false ;
45
+ m_to_coda = false ;
46
+
47
+ m_print_switches.clear ();
48
+
49
+ num_voices = 0 ;
50
+ m_voices.clear ();
51
+ // std::vector<Instrument> m_instruments;
52
+ note_start_idx = 0 ;
53
+ num_notes_parsed = 0 ;
54
+ }
55
+
23
56
public:
24
57
ChipTuneEngineParser (AudioSourceHandler& audio_handler, const WaveformGeneration& waveform_gen)
25
58
: m_audio_handler(audio_handler)
@@ -35,6 +68,8 @@ namespace audio
35
68
// Load tune from a text file with a specific format
36
69
bool load_tune (const std::string& file_path, bool verbose = false )
37
70
{
71
+ clear ();
72
+
38
73
if (!file_path.ends_with (" .ct" ))
39
74
{
40
75
std::cerr << " Wrong file ending in filepath argument. Expected *.ct" << std::endl;
@@ -47,6 +82,8 @@ namespace audio
47
82
std::cerr << " Error opening tune file: " << file_path << std::endl;
48
83
return false ;
49
84
}
85
+
86
+ m_curr_file_path = file_path;
50
87
51
88
if (verbose)
52
89
std::cout << " Parsing Tune" << std::endl;
@@ -184,6 +221,7 @@ namespace audio
184
221
185
222
AudioSourceHandler& m_audio_handler;
186
223
const WaveformGeneration& m_waveform_gen;
224
+ std::string m_curr_file_path;
187
225
std::vector<InstrumentBasic> m_instruments_basic;
188
226
std::vector<InstrumentRingMod> m_instruments_ring_mod;
189
227
std::vector<InstrumentConv> m_instruments_conv;
0 commit comments