-
Notifications
You must be signed in to change notification settings - Fork 13
/
Awful.cpp
13377 lines (11981 loc) · 375 KB
/
Awful.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//////////////////////////////////////////////////////////
// Awful.cpp
#include "stdafx.h"
//#include "resource.h"
#include <windows.h>
#include "awful.h"
#include "awful_audio.h"
#include "awful_audiohost.h"
#include "awful_instruments.h"
#include "awful_elements.h"
#include "awful_params.h"
#include "awful_paramedit.h"
#include "awful_controls.h"
#include "awful_panels.h"
#include "awful_graphJuce.h"
#include "awful_utils_common.h"
#include "awful_effects.h"
#include "awful_events_triggers.h"
#include "awful_tracks_lanes.h"
#include "VSTCollection.h"
#include <direct.h>
#include "shlwapi.h"
#include "awful_renderer.h"
#include "Awful_JuceComponents.h"
#ifdef USE_OLD_JUCE
#include "juce_amalgamated.h"
#else
#include "juce_amalgamated_NewestMerged.h"
#endif
#include "Awful_midi.h"
#include "Awful_JuceWindows.h"
#include "Awful_preview.h"
#include "awful_cursorandmouse.h"
#include "awful_undoredo.h"
#include "rosic/math/rosic_PrimeNumbers.h"
#include "rosic/delaylines/rosic_IntegerDelayLine.h"
#include "rosic/filters/rosic_DampingFilter.h"
#include "rosic/filters/rosic_LowpassHighpass.h"
#include "rosic/filters/rosic_WhiteToPinkFilter.h"
#include "Data sources/metronome_waves.h"
//#include "awful_sf2.h"
///////////////////////////////////////
// Functions declarations
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
////
//// Creation group
extern void CreateElement_EnvelopeCommon(Parameter* param);
extern Command* CreateElement_Command(Scope* scope, CmdType type);
extern Command* CreateElement_Command(Scope* scope, bool preventundo);
extern Vibrate* CreateElement_Vibrate();
extern NoteInstance* CreateElement_Instance_byChar(char character);
extern SlideNote* CreateElement_SlideNote(bool add);
extern Muter* CreateElement_Muter();
extern Break* CreateElement_Break();
extern Slide* CreateElement_Slide(int semitones);
extern Reverse* CreateElement_Reverse();
extern Repeat* CreateElement_Repeater();
extern Pattern* CreateElement_Pattern(int x1, int x2, int y1, int y2);
extern Pattern* CreateElement_Pattern(char* pname, float tk1, float tk2, int tr1, int tr2);
extern Transpose* CreateElement_Transpose(int semitones);
extern Txt* CreateElement_TextString();
extern NoteInstance* CreateElement_Note(Instrument* instr, bool add, bool preventundo);
extern Element* CreateElement_CommonSymbol(ElemType eltype, bool add, bool preventundo);
////
//// Editing group
void SetPosX(double newX, Loc loc);
void SetPatternContext(int mouse_x, int mouse_y);
void Vanish_CleanUp();
void ToggleTextModeToNoteMode();
void ProcessColLane(int mouse_x, int mouse_y, ParamType paramtype, Loc loc, Trk* trk, Pattern* pt, int lx1, int ly1, int lx2, int ly2, bool deflt);
void Selection_UpdateTicks();
void Selection_UpdateCoords();
bool Selection_ToggleElements();
void ChangeCurrentInstrument(Instrument* instr);
void Process_AutoAdvance();
void Process_Resize(int mouse_x, int mouse_y, unsigned flags, Loc loc);
void AuxPos2MainPos();
void MainPos2AuxPos();
void PosUp();
void PosDown();
void SwitchInputMode(CursMode mode);
void Grid2Main();
void Grid_PutInstanceSpecific(Pattern* patt, Instrument *instr, int note, float vol, tframe start_frame, tframe end_frame);
void UpdateScaledImages();
extern void UpdateTime(Loc loc);
void UpdatePerBPM();
void Process_Key_Default(unsigned key, unsigned flags);
void Process_KeyState();
extern void Dequeue_MixCell(Mixcell* mc);
extern void Enqueue_MixCell(Mixcell* mc);
void UpdateScrollbarOutput(ScrollBard* sb);
void ShowVolLane(Trk* trk, Pattern* pt);
void ShowPanLane(Trk* trk, Pattern* pt);
void HideVolLane(Trk* trk, Pattern* pt);
void HidePanLane(Trk* trk, Pattern* pt);
void MoveBorders(int mouse_x, int mouse_y);
void SetMouseImage(unsigned flags);
void DeleteMenu(Menu* menu);
void DoSavePreset(Instrument* instr);
void DoSavePreset(Eff* eff);
void DoLoadPreset(Instrument* instr);
void DoLoadPreset(Eff* eff);
////
//// Elements and params manipulations group
extern Pattern* GetPatternByIndex(int index);
extern bool ResetHighlights(bool* redrawmain, bool* redrawaux);
extern void UpdateElementsVisibility();
void MovePickedUpElements(int mx, int my, bool shift);
void ClonePickedToNew(float dtick, int dtrack);
bool PickUpElements();
void DropPickedElements();
extern void Relocate_Element(Element* el);
void LocateElement(Element* el);
extern void UpdateAllElements(Pattern* pt, bool tonly);
void CleanupElements();
void CleanupEffects();
void CleanupAll();
void UpdateNavBarsData();
void UpdateAuxNavBarOnly();
void UpdateParamIndex();
void UpdatePatternIndex();
void UpdateEffIndex();
Eff* GetEffByIndex(int index);
void UpdateInstrumentIndices();
void UpdateEffIndices();
void UpdatePatternIndices();
void UpdateParamIndices();
////
//// Adders and removers group
extern void AddSamplent(Samplent* s);
extern void AddCommand(Command* c);
extern void AddNewElement(Element* data);
extern void HardDelete(Element* el, bool preventundo);
extern void SoftDelete(Element* el, bool preventundo);
extern void SoftUnDelete(Element *el);
extern bool DeleteElement(Element* el, bool flush, bool preventundo);
extern Element* NextElementToDelete(Element* eltodel);
extern void Delete_Slide(SlideNote* sl);
extern void AddNewControl(Control* ctrl, Panel* owner);
extern void RemoveControlCommon(Control* ctrl);
extern void Add_VU(VU* vu);
extern void Remove_VU(VU* vu);
extern void AddEff(Eff* eff);
extern void RemoveEff(Eff* eff);
extern void Add_PEdit(PEdit* pe);
extern void Remove_PEdit(PEdit* pe);
void Add_Panel(Panel* p);
void AddGlobalParam(Parameter* param);
void RemoveGlobalParam(Parameter* param);
////
//// Checkers group
bool CursModeCorrespondsToCursorMode();
bool CheckDeletionSkip(Element* eltocheck, Element* eltodel);
Element* CheckElementsHighlights(int mx, int my);
PEdit* CheckPEditHighlights(int mx, int my);
Pattern* CheckPosForPatterns(float tick, int trkline);
Element* CheckCursorVisibility();
////
//// Scaling functions group
void DecreaseScale(bool mouse);
void IncreaseScale(bool mouse);
void SetScale(float scale);
void UpdatePerScale();
////
//// Instruments initialisation group
void Load_Default_Instruments();
void ScanDirForVST(char *path, char mode, FILE* fhandle, ScanThread* thread);
static void Init_InternalPlugins();
static void Init_ScanForVST(ScanThread* thread);
void ClearVSTListFile();
////
//// System group
void ReleaseDataOnExit();
//// Libsndfile library
SNDFILE* sf_open(const char *path, int mode, SF_INFO *sfinfo);
sf_count_t sf_readf_float(SNDFILE *sndfile, float *ptr, sf_count_t frames);
//This is a piece of shit
VSTCollection *pVSTCollector;
CPluginList *pModulesList;
char splash_string[MAX_NAME_STRING];
Renderer *pRenderer;
RNDR_CONFIG_DATA_T renderConfig;
//This global parameter holds sample buffer lenght used by renderer and input/output devices
int gBuffLen;
AwfulMidiWrapper *pMidiHost;
//Crappy shitty hack to get slider rendered when Plugin Editor window is in focus and
//we are changing parameters - hence slider needs to be updated and rendered in out-of-focus window
HWND gHwnd;
#if (SPLASH_SCREEN == TRUE)
HWND splash_hwnd;
#endif
//////////////////////////////////////
////////////////////////////////////////
// G l o b a l s t u f f
// Cursor types
HCURSOR VSCursor; // vertical resize
HCURSOR HSCursor; // horizontal resize
HCURSOR ArrowCursor; // plain arrow
// Raw selection rectangle coordinates
int SX1;
int SY1;
int SX2;
int SY2;
// Baked selection rectangle coordinates. -1 means absence of selection rectangle
int SelX1;
int SelY1;
int SelX2;
int SelY2;
int LX1;
int LX2;
int LooX1;
int LooX2;
// Start and end tick of selection
float SelTick1;
float SelTick2;
// Start and end tick of looping
float LooTick1;
float LooTick2;
// Selection is active
bool Sel_Active;
// Looping is active
bool Looping_Active;
// Number of selected items
int Num_Selected;
// Number of buffered items (cut/copied)
int Num_Buffered;
// The upper left corner of buffered stuff
float BuffTick;
int BuffLine;
// Mix browser works in browsing mode (opposing to track controls mode)
bool mixbrowse;
// Whethter mixcenter (track controls and mixbrowser) is visible
bool mixcentervisible;
// Main coordinates (represent the outer line of the main grid)
int MainX1;
int MainX2;
int MainY1;
int MainY2;
// Main grid inner coordinates
int GridX1;
int GridX2;
int GridY1;
int GridY2;
int numFieldLines;
// Main grid quant size
float quantsize;
// Main grid line offset
int OffsLine;
int bottomIncr;
// Main grid tick offset
float OffsTick;
// Main grid tick width
float tickWidth;
float tickWidthBack; // Additional variable used for proper zooming
// Main grid line height
int lineHeight;
int st_tickWidth;
// Aux grid inner coordinates
int GridXS1;
int GridXS2;
int GridYS1;
int GridYS2;
int numAuxLines;
// Main Aux coordinates
int AuxX1;
int AuxX2;
int AuxY1;
int AuxY2;
// Aux mixer coord
int mixHeading;
int MixChanWidth;
int PattX1;
int PattX2;
int PattY1;
int PattY2;
int PtDrawX1;
int PtDrawX2;
int PtDrawY1;
int PtDrawY2;
int LAuxH;
// Aux vols/pans mode workarea coordinates
int AuxRX1;
int AuxRX2;
int AuxRY1;
int AuxRY2;
int AuxHeight;
int AuxKeysHeight;
// Mixer whole area coordinates
int MixX;
int MixY;
int MixW;
int MixH;
int mixX;
int mixY;
int mixW;
int mixH;
// Mixer vertical scrolling offset
int MixVOffs;
int MixCenterWidth;
int DefaultMixCenterWidth;
// Mixer width including mixbrowser area
int MixerWidth;
// Mixer master area height
int MixMasterHeight;
// Mixcell sizes
int MixCellWidth;
int MixCellBasicHeight;
int MixCellGap;
// Piano keys coordinates (in pianoroll mode)
int keyX;
int keyY;
int keyW;
int keyH;
// x-range of control panel
int CtrlPanelXRange;
// Control panel area sizes
int CtrlPanelHeight;
int CtrlPanelWidth;
int CtrlAdvance;
int TranspAdvance;
// Static grid x-bounds (postponed)
int StX1;
int StX2;
// Browser heading height
int brw_heading;
// Navigation bar (main bar) height
int NavHeight;
// Playback scale bar height
int LinerHeight;
// Instruments panel sizes
int InstrCellWidth;
int InstrPanelWidth;
int InstrPanelHeight;
int InstrFoldedHeight;
int InstrUnfoldedHeight;
int InstrAliasOffset;
int InstrCenterOffset;
// Gen browser sizes
int GenBrowserWidth;
int GenBrowserHeight;
int GenBrowserGap;
// Time info
int curr_min;
int curr_sec;
int curr_msec;
int total_min;
int total_sec;
// Position info
int curr_bar;
int curr_beat;
float curr_step;
// Key cursor global data struct
Cursor C;
// Cursor global data
int CursX;
int CursY;
int CursX0;
float CTick;
int CLine;
// Mouse global data struct
Mouse M;
// Main panels
CtrlPanel* CP;
InstrPanel* IP;
Aux* aux_panel;
Browser* genBrw;
Browser* mixBrw;
StaticArea* st;
ScrollBard* main_bar;
ScrollBard* main_v_bar;
// Master audio data
Master mAster;
// JUCE base component
MainComponent* MC;
// JUCE windows
AwfulWindow* MainWnd;
ConfigWindow* ConfigWnd;
RenderWindow* RenderWnd;
SampleWindow* SmpWnd;
// Main window width and height
int WindWidth;
int WindHeight;
unsigned int RenderInterpolationMethod;
unsigned int WorkingInterpolationMethod;
//Global variable initialized at program start-up
char * szWorkingDirectory;
// Just moved some stuff
bool JustMoved;
// Double click timed out flag
bool DBClickTimeout = true;
// Whether static grid is visible
bool static_visible;
bool followPos;
bool scrolling;
Butt* scrollbt;
// Instruments list and other relative data
Instrument* first_instr;
Instrument* last_instr;
Instrument* first_instr_del;
Instrument* last_instr_del;
int num_instrs;
Instrument* current_instr;
Instrument* overriding_instr;
// Timing related global vars
float beats_per_minute;
float beats_per_minute_temp;
int beats_per_bar;
int ticks_per_beat;
float frames_per_tick;
// Seconds per one tick
float seconds_in_tick;
// Some auxiliary stuff
float one_divided_per_frames_per_tick; // 1 divided on seconds_in_tick (== ticks per second)
float one_divided_per_sample_rate;
// Playback x coord integer and float
int currPlayX;
double currPlayX_f;
float framesPerPixel;
int refresh_rate;
int refresh_counter;
// Metronome flag
bool Metronome_ON;
// Main playback
bool Playing;
// Rendering is in progress
bool Rendering;
// Recording is ON
bool Recording;
// Base octave
int Octave;
// Relative octave
int relOctave;
// The base note (C-5 commonly)
int baseNote;
float fSampleRate;
// Number of items in deletion stack
int delCount;
// The deletion stack
Element* delList[100];
// Grids are represented by patterns. Field is the main grid.
Pattern* field_pattern;
// Playback pattern to set for Aux.
Pattern* aux_Pattern;
// Original patterns list
Pattern* first_base_pattern;
Pattern* last_base_pattern;
// All elements list
Element* firstElem;
Element* lastElem;
// Active commands list
Trigger* first_active_command_trigger;
Trigger* last_active_command_trigger;
// Global active triggers list
Trigger* first_global_active_trigger;
Trigger* last_global_active_trigger;
// Effects list
Eff* first_eff;
Eff* last_eff;
// Effects list
Parameter* first_rec_param;
Parameter* last_rec_param;
// Active patterns list
Trigger* first_active_pattern_trigger;
Trigger* last_active_pattern_trigger;
// Active additional playbacks list
Playback* first_active_playback;
Playback* last_active_playback;
// PEdit list
PEdit* firstPE;
PEdit* lastPE;
// Controls list
Control* firstCtrl;
Control* lastCtrl;
// Params list
Parameter* firstParam;
Parameter* lastParam;
// Volume meters list
VU* firstVU;
VU* lastVU;
// Panels list
Panel* firstPanel;
Panel* lastPanel;
// Main grid tracks data list and auxilliary data
Trk* first_trkdata;
Trk* last_trkdata;
Trk* top_trk;
Trk* bottom_trk;
// Alias records list
AliasRecord* first_alias_record;
AliasRecord* last_alias_record;
// Bunches list
TrkBunch* bunch_first;
TrkBunch* bunch_last;
// Pianokeys data (postponed)
int keys_offset;
int keys_width;
// data buffer for analysis
float ring[1024];
int ringPos;
int ringSize;
// Keyboard mappings array
unsigned keymap[256];
// Main window handle
HWND hWnd;
// This shit is needed for displaying Hint content
unsigned int HintTimer;
Control* MouseControl;
// Different precalculated wavetables
float wt_sine[WT_SIZE];
float wt_cosine[WT_SIZE];
float wt_saw[WT_SIZE];
float wt_triangle[WT_SIZE];
float wt_coeff;
float wt_angletoindex;
// Solo data
Instrument* solo_Instr;
Trk* solo_Trk;
Mixcell* solo_Mixcell;
MixChannel* solo_MixChannel;
// Various flags
bool skip_input = false;
bool out_from_dialog = false;
bool auto_advance;
bool post_menu_update;
bool firsttime_plugs_scanned;
// Playback data for both grids
Playback* pbkMain;
Playback* pbkAux;
// Zero event for preview purposes
Event* ev0;
UndoManagerC* undoMan;
long paramIndex;
long pattIndex;
long instrIndex;
long effIndex;
int PianorollLineHeight;
tframe lastFrame;
char lastchar[2] = {0, 0};
// Basic project info data
ProjectData PrjData;
// Various mouse cursor shapes
MouseCursor* cursCopy;
MouseCursor* cursClone;
MouseCursor* cursSlide;
MouseCursor* cursBrush;
MouseCursor* cursSelect;
HANDLE hAudioProcessMutex;
bool MakePatternsFat;
bool JustClickedPattern;
bool RememberLengths;
bool AutoBindPatterns;
bool PatternsOverlapping;
bool RescanPluginsAutomatically;
bool ProjectLoadingInProgress;
bool ChangesHappened;
int rVer = 101;
int rDay = 7, rMonth = 7, rYear = 2010;
String userName;
bool bDebug;
File* lastsessions[10];
int numLastSessions;
Sample* barsample = NULL;
Sample* beatsample = NULL;
// In release build, we retrieve the target path a bit differently
bool obtainReleasePathDir = false;
void MakeCoolVUFallDownEffectYo()
{
CP->MVol->vu->SetLR(Random::getSystemRandom().nextFloat()*0.5f + 0.5f,
Random::getSystemRandom().nextFloat()*0.5f + 0.5f);
Instrument* i = first_instr;
while(i != NULL)
{
i->vu->SetLR(Random::getSystemRandom().nextFloat()*0.5f + Random::getSystemRandom().nextFloat()*0.5f,
Random::getSystemRandom().nextFloat()*0.5f + Random::getSystemRandom().nextFloat()*0.5f);
i = i->next;
}
}
void ChangesIndicate()
{
if(!ChangesHappened)
{
R(Refresh_All);
}
ChangesHappened = true;
if(!ProjectLoadingInProgress)
{
MainWnd->UpdateTitle();
}
}
void ResetChangesIndicate()
{
ChangesHappened = false;
}
void ProjectData::Init()
{
newproj = true;
strcpy(projname, "Untitled");
projpath;
//memset(projpath, 0, MAX_PATH_STRING);
file = NULL;
}
void ProjectData::SetName(String name)
{
if(name.length()<= MAX_NAME_STRING)
{
name.copyToBuffer(projname, MAX_NAME_STRING);
}
}
void CleanElements()
{
AlertWindow w (T("Warning"),
T("Do you really want to clean all existing elements (no undo)?"),
AlertWindow::WarningIcon);
w.setSize(122, 55);
w.addButton (T("Yes"), 1, KeyPress (KeyPress::returnKey, 0, 0));
w.addButton (T("No"), 0, KeyPress (KeyPress::returnKey, 0, 0));
int result = w.runModalLoop();
if(result == 1) // if they picked 'OK'
{
if(Playing == true)
{
StopMain(true);
CP->play_butt->Release();
}
else if(aux_panel->playing == true)
{
aux_panel->Stop();
aux_panel->playbt->Release();
}
if(C.mode == CMode_NotePlacing)
{
ToggleTextModeToNoteMode();
}
Element* elnext;
Element* el = firstElem;
while(el != NULL)
{
elnext = NextElementToDelete(el);
DeleteElement(el, true, true);
el = elnext;
}
R(Refresh_All);
}
else
{
return;
}
}
void CleanProject()
{
WaitForSingleObject(hAudioProcessMutex, INFINITE);
Selection_Reset();
Looping_Reset();
if(Playing == true)
{
StopMain(true);
CP->play_butt->Release();
}
else if(aux_panel->playing == true)
{
aux_panel->Stop();
aux_panel->playbt->Release();
}
else
{
// Just stop any sounding
StopMain(true);
}
aux_panel->AuxReset();
pbkAux->SetPlayPatt(aux_Pattern); // force setting to blank pattern
if(C.mode == CMode_NotePlacing)
{
ToggleTextModeToNoteMode();
}
Element* elnext;
Element* el = firstElem;
while(el != NULL)
{
elnext = NextElementToDelete(el);
DeleteElement(el, true, true);
el = elnext;
}
Instrument* inext;
Instrument* i = first_instr;
while(i != NULL)
{
inext = i->next;
IP->RemoveInstrument(i);
i = inext;
}
aux_panel->current_eff = NULL;
if(mixBrw->brwmode == Browse_Presets || mixBrw->brwmode == Browse_Params)
{
mixBrw->Update();
}
Eff* effnext;
Eff* eff = first_eff;
while(eff != NULL)
{
effnext = eff->next;
RemoveEff(eff);
eff = effnext;
}
for(int mc = 0; mc < NUM_MIXCHANNELS; mc++)
{
aux_panel->mchan[mc].routestr->SetString("--");
aux_panel->mchan[mc].mc_main->params->Reset();
aux_panel->mchan[mc].amount1->Reset();
aux_panel->mchan[mc].amount2->Reset();
aux_panel->mchan[mc].amount3->Reset();
}
solo_Instr = NULL;
solo_Trk = NULL;
solo_Mixcell = NULL;
solo_MixChannel = NULL;
//UpdateParamIndex();
//UpdatePatternIndex();
//UpdateEffIndex();
//UpdateInstrumentIndex();
baseNote = 60;
relOctave = 0;
beats_per_minute = 120; // BPM
ticks_per_beat = 4; // TPB =)
beats_per_bar = 4; // BPB =)))
Octave = 5;
lastFrame = 0;
UpdatePerBPM();
UpdateQuants();
// Position cursor, playback pos and mainbar
SetPosX(0 - OffsTick*tickWidth, Loc_MainGrid);
SetScale(tickWidthBack);
aux_panel->SetScale(aux_panel->tickWidthBack);
OffsLine = 0;
C.ExitToDefaultMode();
C.SetPattern(field_pattern, Loc_MainGrid);
C.SetPos(8, 4);
main_bar->SetOffset(0);
main_v_bar->SetOffset(0);
aux_panel->mix_sbar->SetOffset(0);
PrjData.projpath = "";
PrjData.SetName("Untitled");
ResetChangesIndicate();
MainWnd->UpdateTitle();
ReleaseMutex(hAudioProcessMutex);
}
void ActualizeStepSeqPositions()
{
Element* el = firstElem;
while(el != NULL)
{
if(el->IsPresent() && el->IsInstance() && el->patt->ptype == Patt_StepSeq)
{
el->SetTrackLine(((NoteInstance*)el)->instr->index);
}
el = el->next;
}
}
void LoadElementsFromNode(XmlElement* xmlMainNode, Pattern* pttarget)
{
XmlElement* xmlChild = NULL;
forEachXmlChildElementWithTagName(*xmlMainNode, xmlChild, T("Element"))
{
ElemType type = (ElemType)xmlChild->getIntAttribute(T("Type"));
float stick = (float)xmlChild->getDoubleAttribute(T("StartTick"));
float etick = (float)xmlChild->getDoubleAttribute(T("EndTick"));
float ticklength = (float)xmlChild->getDoubleAttribute(T("TickLength"));
int trackline = xmlChild->getIntAttribute(T("TrackLine"));
int pattindex = xmlChild->getIntAttribute(T("PattIndex"));
Pattern* patt;
if(pttarget == NULL)
{
patt = GetPatternByIndex(pattindex);
}
else
{
patt = pttarget;
}
if(patt != NULL)
{
Element* el = NULL;
C.SaveState();
C.SetPos(stick, trackline);
C.SetPattern(patt, patt == field_pattern ? Loc_MainGrid : Loc_SmallGrid);
switch(type)
{
case El_TextString:
{
el = CreateElement_TextString();
}break;
case El_GenNote:
case El_Samplent:
{
int index = (int)xmlChild->getIntAttribute(T("InstrIndex"));
Instrument* instr = GetInstrumentByIndex(index);
if(instr != NULL)
{
el = CreateElement_Note(instr, true, true);
}
}break;
case El_Command:
{
el = CreateElement_Command(NULL, true);
}break;
case El_Mute:
case El_Break:
case El_SlideNote:
case El_Slider:
case El_Reverse:
case El_Vibrate:
case El_Transpose:
{
el = CreateElement_CommonSymbol(type, true, true);
}break;
}
if(el != NULL)
{
el->Load(xmlChild);
el->Update();
}
C.RestoreState();
}
}
}