Icons for Radium and Shellplayer.
[AROS-Contrib.git] / MultiMedia / radium / common / player_startstop.c
blobf7ba0cc05b49f78821bde55ec65c0c458d4e3635
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. */
25 #ifdef AMIAROS
26 #include <proto/dos.h> // Temporary solution. This is not portable.
27 #endif
29 #include "nsmtracker.h"
30 #include "playerclass.h"
31 #include "placement_proc.h"
32 #include "OS_Player_proc.h"
33 #include "PEQrealline_proc.h"
34 #include "PEQblock_proc.h"
35 #include "PEQnotes_proc.h"
36 #include "instruments_proc.h"
37 #include "blocklist_proc.h"
38 #include "OS_Ptask2Mtask_proc.h"
39 #include "time_proc.h"
40 #include "PEQ_clock_proc.h"
41 #include "gfx_upperleft_proc.h"
42 #include "OS_Bs_edit_proc.h"
43 #include "list_proc.h"
45 #include "player_proc.h"
48 extern STime dastime;
51 /******************** NOTES ******************************
53 Even more "methods" for the playerclass struct.
55 *********************************************************/
57 extern PlayerClass *pc;
58 extern struct Root *root;
60 extern void (*Ptask2MtaskCallBack)(void);
62 void PlayStopReally(bool doit){
63 pc->isplaying=false;
64 pc->initplaying=false;
66 #ifdef AMIAROS
67 while(pc->peq!=NULL) Delay(1); //Amiga-spesific, etc.
68 #endif
70 StopAllInstruments();
72 if(doit) (*Ptask2MtaskCallBack)();
74 dastime=0;
76 GFX_UpdateQuantitize(root->song->tracker_windows,root->song->tracker_windows->wblock);
79 void PlayStop(void){
80 if(! pc->isplaying){
81 StopAllInstruments();
82 return;
84 PlayStopReally(true);
88 void PlayBlock(
89 struct Blocks *block,
90 Place *place
93 pc->initplaying=true;
95 pc->playpos=0;
97 pc->playtype=PLAYBLOCK;
99 pc->block=block;
101 root->curr_block=pc->block->l.num;
102 debug("root->curr_block: %d\n",root->curr_block);
104 pc->isplaying=true;
105 (*Ptask2MtaskCallBack)();
106 pc->isplaying=false;
108 InitPEQclock();
109 InitPEQrealline(block,place);
110 InitPEQblock(block,place);
111 InitAllPEQnotes(block,place);
113 StartPlayer(); // An OS spesific function.
114 pc->isplaying=true;
117 pc->initplaying=false;
120 void PlayBlockFromStart(struct Tracker_Windows *window){
121 Place place;
123 struct WBlocks *wblock=window->wblock;
125 PlayStopReally(false);
126 PlaceSetFirstPos(&place);
128 root->setfirstpos=true;
129 pc->seqtime=0;
130 PlayBlock(wblock->block,&place);
133 void PlayBlockCurrPos(struct Tracker_Windows *window){
134 struct WBlocks *wblock;
135 Place *place;
136 PlayStopReally(false);
138 root->setfirstpos=false;
140 wblock=window->wblock;
142 if(wblock->curr_realline==0) root->setfirstpos=true;
144 place=&wblock->reallines[wblock->curr_realline]->l.p;
145 pc->seqtime=-Place2STime(wblock->block,place);
147 debug("contblock, time: %d\n",pc->seqtime);
149 PlayBlock(wblock->block,place);
152 void PlaySong(
153 Place *place,
154 int playpos
156 struct Blocks *block;
158 debug("haaasfdfsafsa, root->song->length: %d\n\n\n",root->song->length);
159 pc->initplaying=true;
161 block=BL_GetBlockFromPos(playpos);
163 debug("blocknum:%d\n",block->l.num);
165 pc->playpos=playpos;
167 root->curr_playlist=playpos;
169 pc->playtype=PLAYSONG;
171 pc->block=block;
173 root->curr_block=block->l.num;
174 pc->isplaying=true;
175 (*Ptask2MtaskCallBack)();
176 pc->isplaying=false;
178 InitPEQclock();
179 InitPEQrealline(block,place);
180 InitPEQblock(block,place);
181 InitAllPEQnotes(block,place);
183 StartPlayer(); // An OS spesific function.
184 pc->isplaying=true;
187 pc->initplaying=false;
191 void PlaySongFromStart(struct Tracker_Windows *window){
193 Place place;
195 PlaceSetFirstPos(&place);
197 PlayStopReally(false);
199 BS_SelectPlaylistPos(0);
200 debug("root->curr_block: %d\n",root->curr_block);
201 root->setfirstpos=true;
202 pc->seqtime=0;
204 InitAllInstrumentsForPlaySongFromStart();
206 PlaySong(&place,0);
209 void PlaySongCurrPos(struct Tracker_Windows *window){
210 struct Blocks *block;
211 struct WBlocks *wblock;
212 Place *place;
213 int playpos;
214 bool changeblock=false;
216 wblock=window->wblock;
218 PlayStopReally(false);
220 root->setfirstpos=false;
222 playpos=root->curr_playlist;
224 block=BL_GetBlockFromPos(playpos);
225 if(block==NULL) return;
227 if(wblock->l.num!=block->l.num){
228 wblock=ListFindElement1(&window->wblocks->l,block->l.num);
229 changeblock=true;
230 root->setfirstpos=true;
234 ! changeblock &&
235 playpos==root->song->length-1 &&
236 wblock->curr_realline==wblock->num_reallines
238 return;
241 if(wblock->curr_realline==0) root->setfirstpos=true;
244 debug("contsong, playpos: %d , root->curr_block: %d\n",playpos,root->curr_block);
246 if(changeblock){
247 place=PlaceGetFirstPos();
248 pc->seqtime=0;
249 }else{
250 place=&wblock->reallines[wblock->curr_realline]->l.p;
251 pc->seqtime=-Place2STime(wblock->block,place);
253 debug("contsong, time: %d, playpos: %d , root->curr_block: %d\n",pc->seqtime,playpos,root->curr_block);
255 place->line++;
256 debug("nextline: %d\n",Place2STime(wblock->block,place));
257 place->line--;
259 PlaySong(place,playpos);