1 /* Copyright 2000 Kjetil S. Matheussen
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License
5 as published by the Free Software Foundation; either version 2
6 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #include "nsmtracker.h"
21 #include "visual_proc.h"
22 #include "list_proc.h"
23 #include "gfx_wtrackheaders_proc.h"
24 #include "player_proc.h"
25 #include "undo_tracks_proc.h"
27 #include "patch_proc.h"
31 void SelectPatch(struct Tracker_Windows
*window
,struct Tracks
*track
){
32 struct Instruments
*instrument
=track
->instrument
;
42 numpatches
=ListFindNumElements1(&instrument
->patches
->l
);
44 reqtype
=GFX_OpenReq(window
,70,(int)(numpatches
+50),"Select Patch");
46 if(instrument
->patches
==NULL
){
47 patch
=talloc(sizeof(struct Patch
));
48 if((*instrument
->getPatch
)(window
,reqtype
,track
,patch
)==PATCH_FAILED
){
49 GFX_CloseReq(window
,reqtype
);
52 Undo_Track_CurrPos(window
);
53 ListAddElement1(&instrument
->patches
,&patch
->l
);
55 while(patch
->name
==NULL
) patch
->name
=GFX_GetString(window
,reqtype
,"Name: ");
56 DrawWTrackHeader(window
,window
->wblock
,window
->wblock
->wtrack
);
57 GFX_CloseReq(window
,reqtype
);
58 (*instrument
->PP_Update
)(instrument
,patch
);
62 menutext
=talloc((size_t)(sizeof(char *)*(numpatches
+1)));
64 patch
=instrument
->patches
;
68 menutext
[lokke
]=patch
->name
;
69 patch
=NextPatch(patch
);
73 menutext
[lokke
]="New patch";
75 selection
=GFX_Menu(window
,reqtype
,"Select Patch",(int)(numpatches
+1),menutext
);
78 GFX_CloseReq(window
,reqtype
);
82 if(selection
==numpatches
){
83 patch
=talloc(sizeof(struct Patch
));
84 if((*instrument
->getPatch
)(window
,reqtype
,track
,patch
)==PATCH_FAILED
){
85 GFX_CloseReq(window
,reqtype
);
88 Undo_Track_CurrPos(window
);
89 ListAddElement1_ff(&instrument
->patches
,&patch
->l
);
91 while(patch
->name
==NULL
) patch
->name
=GFX_GetString(window
,reqtype
,"Name: ");
93 Undo_Track_CurrPos(window
);
95 patch
=instrument
->patches
;
96 while(lokke
<selection
){
98 patch
=NextPatch(patch
);
102 GFX_CloseReq(window
,reqtype
);
106 DrawWTrackHeader(window
,window
->wblock
,window
->wblock
->wtrack
);
108 (*instrument
->PP_Update
)(instrument
,patch
);
113 void PATCH_playNoteCurrPos(struct Tracker_Windows
*window
,int notenum
){
114 struct Tracks
*track
=window
->wblock
->wtrack
->track
;
115 struct Patch
*patch
=track
->patch
;
117 if(patch
==NULL
|| notenum
<0 || notenum
>127) return;
119 (*patch
->playnote
)(notenum
,patch
->standardvel
,track
,NULL
);
123 void PATCH_stopNoteCurrPos(struct Tracker_Windows
*window
,int notenum
){
124 struct Tracks
*track
=window
->wblock
->wtrack
->track
;
125 struct Patch
*patch
=track
->patch
;
127 if(patch
==NULL
|| notenum
<0 || notenum
>127) return;
129 (*patch
->stopnote
)(notenum
,patch
->standardvel
,track
,NULL
);