1// MIT License
2
3// Copyright (c) 2017 Vadim Grigoruk @nesbox // grigoruk@gmail.com
4
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11
12// The above copyright notice and this permission notice shall be included in all
13// copies or substantial portions of the Software.
14
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23#pragma once
24
25#include "studio/studio.h"
26
27typedef struct Music Music;
28
29struct Music
30{
31 Studio* studio;
32 tic_mem* tic;
33 tic_music* src;
34
35 u8 track;
36 s32 frame;
37
38 struct
39 {
40 s32 pos;
41 s32 start;
42 bool active;
43
44 } scroll;
45
46 bool beat34;
47 bool follow;
48 bool sustain;
49 bool loop;
50 bool on[TIC_SOUND_CHANNELS];
51
52 struct
53 {
54 s32 octave;
55 s32 sfx;
56 } last;
57
58 struct
59 {
60 s32 col;
61 tic_point edit;
62
63 struct
64 {
65 tic_point start;
66 tic_rect rect;
67 bool drag;
68 } select;
69 } tracker;
70
71 struct
72 {
73 s32 col;
74 tic_point edit;
75 s8 note[TIC_SOUND_CHANNELS];
76 } piano;
77
78 enum
79 {
80 MUSIC_TRACKER_TAB,
81 MUSIC_PIANO_TAB,
82 MUSIC_TAB_COUNT,
83 } tab;
84
85 struct
86 {
87 const char* label;
88 s32 x;
89 s32 start;
90 } drag;
91
92 u32 tickCounter;
93
94 struct History* history;
95
96 void(*tick)(Music*);
97 void(*event)(Music*, StudioEvent);
98};
99
100void initMusic(Music*, Studio* studio, tic_music* src);
101void freeMusic(Music* music);
102