~ubuntu-branches/ubuntu/karmic/muse/karmic-proposed

« back to all changes in this revision

Viewing changes to mplugins/rhythm.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2002-04-23 17:28:23 UTC
  • Revision ID: james.westby@ubuntu.com-20020423172823-w8yplzr81a759xa3
Tags: upstream-0.5.2
ImportĀ upstreamĀ versionĀ 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=========================================================
 
2
//  MusE
 
3
//  Linux Music Editor
 
4
//  $Id: rhythm.h,v 1.1 2002/02/27 11:52:59 muse Exp $
 
5
//
 
6
//  (C) Copyright 2001 Werner Schweer (ws@seh.de)
 
7
//
 
8
//  This code is an adaption of the random rhythm generator taken
 
9
//  from "The JAZZ++ Midi Sequencer"
 
10
//  Copyright (C) 1994-2000 Andreas Voss and Per Sigmond, all
 
11
//  rights reserved.
 
12
//  Distributed under the GNU General Public License
 
13
//=========================================================
 
14
 
 
15
#ifndef __RHYTHM_H__
 
16
#define __RHYTHM_H__
 
17
 
 
18
#include "rhythmbase.h"
 
19
 
 
20
class tTrack;
 
21
class tEventWin;
 
22
class tSong;
 
23
class tBarInfo;
 
24
 
 
25
#define MAX_GROUPS  5
 
26
#define MAX_KEYS   20
 
27
 
 
28
class Xml;
 
29
 
 
30
#if 0
 
31
//---------------------------------------------------------
 
32
//   tRhyGroup
 
33
//---------------------------------------------------------
 
34
 
 
35
struct tRhyGroup {
 
36
      int contrib;
 
37
      int listen;
 
38
 
 
39
      tRhyGroup() {
 
40
            listen = 0;
 
41
            contrib = 0;
 
42
            }
 
43
//      void write(int, Xml&);
 
44
//      void read(Xml&);
 
45
      };
 
46
 
 
47
//---------------------------------------------------------
 
48
//   tRhyGroups
 
49
//---------------------------------------------------------
 
50
 
 
51
struct tRhyGroups {
 
52
      tRhyGroup g[MAX_GROUPS];
 
53
      tRhyGroup& operator [] (int i) { return g[i]; }
 
54
 
 
55
//      void write(int, Xml&);
 
56
//      void read(Xml&);
 
57
      };
 
58
 
 
59
//---------------------------------------------------------
 
60
//   tRhythm
 
61
//---------------------------------------------------------
 
62
 
 
63
class tRhythm
 
64
      {
 
65
      friend class tRhythmWin;
 
66
 
 
67
      char* label;
 
68
 
 
69
//      tRndArray rhythm;
 
70
//      tRndArray length;
 
71
//      tRndArray veloc;
 
72
 
 
73
      int steps_per_count;
 
74
      int count_per_bar;
 
75
      int n_bars;
 
76
      int keys[MAX_KEYS];
 
77
      int n_keys;
 
78
      int mode;
 
79
      int parm;
 
80
 
 
81
      int randomize;
 
82
      tRhyGroups groups;
 
83
//      tRndArray history;
 
84
 
 
85
      // set by GenInit()
 
86
      long start_clock;
 
87
      long next_clock;
 
88
 
 
89
//      void GenGroup(tRndArray& out, int grp, tBarInfo &bi, tRhythm *rhy[], int n_rhy);
 
90
      int Clock2i(long clock, tBarInfo &bi) const;
 
91
      int ClocksPerStep(tBarInfo &bi) const;
 
92
 
 
93
   public:
 
94
      tRhythm(int key);
 
95
      tRhythm(const tRhythm &o);
 
96
      tRhythm & operator= (const tRhythm &o);
 
97
      virtual ~tRhythm();
 
98
 
 
99
      char const * GetLabel() { return label; }
 
100
      void SetLabel(char const *);
 
101
 
 
102
      void Generate(tTrack *track, long fr_clock, long to_clock, long ticks_per_bar);
 
103
      void Generate(tTrack *track, tBarInfo &bi, tRhythm *rhy[], int n_rhy);
 
104
      void GenInit(long start_clock);
 
105
      void GenerateEvent(tTrack *track, long clock, short vel, short len);
 
106
 
 
107
      void write(int, Xml&);
 
108
      void read(Xml&);
 
109
      };
 
110
#endif
 
111
 
 
112
//---------------------------------------------------------
 
113
//   RhythmGen
 
114
//---------------------------------------------------------
 
115
 
 
116
class RhythmGen : public RhythmBase
 
117
      {
 
118
      Q_OBJECT
 
119
#if 0
 
120
    wxPanel    *inst_panel;
 
121
    wxText     *label;
 
122
    wxSlider   *steps_per_count;
 
123
    wxSlider   *count_per_bar;
 
124
    wxSlider   *n_bars;
 
125
    wxListBox  *instrument_list;
 
126
    wxCheckBox *rand_checkbox;
 
127
 
 
128
    wxPanel    *group_panel;
 
129
    wxListBox  *group_list;
 
130
    wxSlider   *group_contrib;
 
131
    wxSlider   *group_listen;
 
132
    int        act_group;
 
133
 
 
134
    tArrayEdit    *length_edit;
 
135
    tArrayEdit    *veloc_edit;
 
136
    tRhyArrayEdit *rhythm_edit;
 
137
 
 
138
    enum       { MAX_INSTRUMENTS = 20 };
 
139
    tRhythm    *instruments[MAX_INSTRUMENTS];
 
140
    int        n_instruments;
 
141
    int        act_instrument;  // -1 if none
 
142
 
 
143
    // this one is edited and copied from/to instruments[i]
 
144
    tRhythm    edit;
 
145
 
 
146
    // ignore Updates while creating the window (motif)
 
147
    Bool in_create;
 
148
 
 
149
    // callbacks
 
150
    static void ItemCallback(wxItem& item, wxCommandEvent& event);
 
151
    static void SelectInstr(wxListBox& list, wxCommandEvent& event);
 
152
    static void SelectGroup(wxListBox& list, wxCommandEvent& event);
 
153
    static void Add(wxButton &but, wxCommandEvent& event);
 
154
    static void Del(wxButton &but, wxCommandEvent& event);
 
155
    static void Generate(wxButton &but, wxCommandEvent& event);
 
156
    static void Help();
 
157
 
 
158
    void Instrument2Win(int i = -1);    // instrument[act_instrument] -> win
 
159
    void Win2Instrument(int i = -1);    // win -> instrument[act_instrument]
 
160
    void AddInstrumentDlg();
 
161
    void AddInstrument(tRhythm *r);
 
162
    void DelInstrument();
 
163
 
 
164
    tEventWin *event_win;
 
165
    tSong     *song;
 
166
 
 
167
    void RndEnable();
 
168
 
 
169
    char *default_filename;
 
170
    int has_changed;
 
171
    wxToolBar *tool_bar;
 
172
    float tb_width, tb_height;
 
173
 
 
174
    void UpInstrument();
 
175
    void DownInstrument();
 
176
    void InitInstrumentList();
 
177
#endif
 
178
      virtual void closeEvent(QCloseEvent*);
 
179
 
 
180
   signals:
 
181
      void hideWindow();
 
182
 
 
183
   public:
 
184
//      virtual void OnMenuCommand(int id);
 
185
//      virtual void OnSize(int w, int h);
 
186
      RhythmGen(QWidget* parent = 0, const char* name = 0, WFlags fo = WType_TopLevel);
 
187
      virtual ~RhythmGen();
 
188
//      void OnPaint();
 
189
//      void GenRhythm();
 
190
//      bool OnClose();
 
191
      };
 
192
 
 
193
#endif
 
194