Icons for Radium and Shellplayer.
[AROS-Contrib.git] / MultiMedia / radium / common / patch.c
blob5633f00ddfad1ea643ac3e6d511921b1f3da09e7
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;
33 struct Patch *patch;
34 char **menutext;
35 NInt numpatches;
36 int lokke;
37 int selection;
38 ReqType reqtype;
40 PlayStop();
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);
50 return;
52 Undo_Track_CurrPos(window);
53 ListAddElement1(&instrument->patches,&patch->l);
54 track->patch=patch;
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);
59 return;
62 menutext=talloc((size_t)(sizeof(char *)*(numpatches+1)));
64 patch=instrument->patches;
66 lokke=0;
67 while(patch!=NULL){
68 menutext[lokke]=patch->name;
69 patch=NextPatch(patch);
70 lokke++;
73 menutext[lokke]="New patch";
75 selection=GFX_Menu(window,reqtype,"Select Patch",(int)(numpatches+1),menutext);
77 if(-1==selection){
78 GFX_CloseReq(window,reqtype);
79 return;
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);
86 return;
88 Undo_Track_CurrPos(window);
89 ListAddElement1_ff(&instrument->patches,&patch->l);
90 track->patch=patch;
91 while(patch->name==NULL) patch->name=GFX_GetString(window,reqtype,"Name: ");
92 }else{
93 Undo_Track_CurrPos(window);
94 lokke=0;
95 patch=instrument->patches;
96 while(lokke<selection){
97 lokke++;
98 patch=NextPatch(patch);
102 GFX_CloseReq(window,reqtype);
104 track->patch=patch;
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);