You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

746 lines
22KB

  1. /* SpiralPlugin
  2. * Copyleft (C) 2000 David Griffiths <dave@pawfal.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include "PoshSamplerPluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_draw.H>
  21. #include <FL/fl_file_chooser.h>
  22. ////////////////////////////////////////////
  23. Fl_WaveDisplay::Fl_WaveDisplay(int x,int y,int w,int h, char *Name) :
  24. Fl_Widget(x,y,w,h,Name),
  25. m_Sample(NULL),
  26. m_StartPos(1),
  27. m_EndPos(10),
  28. m_ViewStart(0),
  29. m_ViewEnd(INT_MAX),
  30. m_PlayPos(0),
  31. m_PlayStart(0),
  32. m_LoopStart(0),
  33. m_LoopEnd(INT_MAX),
  34. m_PosMarker(true)
  35. {
  36. }
  37. Fl_WaveDisplay::~Fl_WaveDisplay()
  38. {
  39. }
  40. void Fl_WaveDisplay::SetSample(const float* s, long len)
  41. {
  42. if (m_Sample) delete m_Sample;
  43. m_Sample = new Sample(s,len);
  44. }
  45. void Fl_WaveDisplay::draw()
  46. {
  47. int ho=h()/2;
  48. fl_color (m_BGColour);
  49. fl_rectf(x(), y(), w(), h());
  50. if (!m_Sample || m_Sample->GetLength()==0) return;
  51. if (m_ViewStart<0) m_ViewStart=0;
  52. if (m_ViewEnd>m_Sample->GetLength()-1) m_ViewEnd=m_Sample->GetLength()-1;
  53. if (m_PlayStart<0) m_PlayStart=0;
  54. if (m_PlayStart>m_Sample->GetLength()-1) m_PlayStart=m_Sample->GetLength()-1;
  55. if (m_LoopStart<0) m_LoopStart=0;
  56. if (m_LoopStart>m_Sample->GetLength()-1) m_LoopStart=m_Sample->GetLength()-1;
  57. if (m_LoopEnd<0) m_LoopEnd=0;
  58. if (m_LoopEnd>m_Sample->GetLength()-1) m_LoopEnd=m_Sample->GetLength()-1;
  59. float Value=0,NextValue=0;
  60. int pos=0;
  61. int Jump=(m_ViewEnd-m_ViewStart)/w();
  62. if (Jump==0) Jump=1;
  63. for(int n=m_ViewStart; n<m_ViewEnd-Jump; n+=Jump)
  64. {
  65. fl_font(fl_font(),10);
  66. if (m_PlayPos>=n && m_PlayPos<n+Jump)
  67. {
  68. fl_color (m_IndColour);
  69. fl_line(x()+pos, y(),
  70. x()+pos, y()+h());
  71. }
  72. if (m_PlayStart>=n && m_PlayStart<n+Jump)
  73. {
  74. fl_color (m_MrkColour);
  75. fl_draw("S",x()+pos+2,y()+h());
  76. fl_line(x()+pos, y(),
  77. x()+pos, y()+h());
  78. }
  79. if (m_LoopStart>=n && m_LoopStart<n+Jump)
  80. {
  81. fl_color (m_MrkColour);
  82. fl_draw("LS",x()+pos+2,y()+h());
  83. fl_line(x()+pos, y(),
  84. x()+pos, y()+h());
  85. }
  86. if (m_LoopEnd>=n && m_LoopEnd<n+Jump)
  87. {
  88. fl_color (m_MrkColour);
  89. fl_draw("LE",x()+pos+2,y()+h());
  90. fl_line(x()+pos, y(),
  91. x()+pos, y()+h());
  92. }
  93. if (n>m_StartPos && n<m_EndPos) fl_color (m_SelColour);
  94. else fl_color (m_FGColour);
  95. Value = NextValue;
  96. // get max
  97. float max=(*m_Sample)[n];
  98. float min=(*m_Sample)[n];
  99. for (int m=n; m<n+Jump; m++)
  100. {
  101. if (max<(*m_Sample)[m]) max=(*m_Sample)[m];
  102. if (min>(*m_Sample)[m]) min=(*m_Sample)[m];
  103. }
  104. min*=ho; max*=ho;
  105. fl_line(x()+pos-1, y()+ho-(int)min,
  106. x()+pos-1, y()+ho-(int)max);
  107. pos++;
  108. }
  109. }
  110. int Fl_WaveDisplay::handle(int event)
  111. {
  112. int xx=Fl::event_x();
  113. int yy=Fl::event_y();
  114. static int DragX,DragY;
  115. static int Mousebutton=0;
  116. static int Holding=0;
  117. static int GrabDist=10;
  118. if (!m_Sample || m_Sample->GetLength()==0) return 1;
  119. if (event==FL_PUSH)
  120. {
  121. GrabDist=(int)((m_ViewEnd-m_ViewStart)*0.03f);
  122. Mousebutton=Fl::event_button();
  123. DragX=xx;
  124. DragY=yy;
  125. if (Mousebutton==1)
  126. {
  127. int MousePos=(xx-x())*((m_ViewEnd-m_ViewStart)/w())+m_ViewStart;
  128. Holding=0;
  129. if (abs(MousePos-m_StartPos)<GrabDist) Holding=1;
  130. else if (abs(MousePos-m_EndPos)<GrabDist) Holding=2;
  131. else if (abs(MousePos-m_PlayStart)<GrabDist) Holding=3;
  132. else if (abs(MousePos-m_LoopStart)<GrabDist) Holding=4;
  133. else if (abs(MousePos-m_LoopEnd)<GrabDist) Holding=5;
  134. else
  135. {
  136. m_StartPos=MousePos;
  137. m_EndPos=MousePos;
  138. }
  139. }
  140. }
  141. if (event==FL_DRAG)
  142. {
  143. if (Mousebutton==1)
  144. {
  145. int MousePos=(xx-x())*((m_ViewEnd-m_ViewStart)/w())+m_ViewStart;
  146. switch (Holding)
  147. {
  148. case 0:
  149. {
  150. if (MousePos>m_EndPos) m_EndPos=MousePos;
  151. else m_StartPos=MousePos;
  152. } break;
  153. case 1:
  154. {
  155. m_StartPos=MousePos;
  156. if (m_StartPos>m_EndPos) Holding=2; // swap
  157. } break;
  158. case 2:
  159. {
  160. m_EndPos=MousePos;
  161. if (m_StartPos>m_EndPos) Holding=1; // swap
  162. } break;
  163. case 3: m_PlayStart=MousePos; break;
  164. case 4: m_LoopStart=MousePos; break;
  165. case 5: m_LoopEnd=MousePos; break;
  166. }
  167. }
  168. if (Mousebutton==2)
  169. {
  170. int Dist=(DragX-xx)*((m_ViewEnd-m_ViewStart)/w());
  171. if (m_ViewStart>0 && m_ViewEnd<m_Sample->GetLength()-1)
  172. {
  173. m_ViewStart+=Dist;
  174. m_ViewEnd+=Dist;
  175. }
  176. else // stop it sticking when at end/beginning
  177. {
  178. if ((Dist>0 && m_ViewStart<=0) ||
  179. (Dist<0 && m_ViewEnd>=m_Sample->GetLength()-1))
  180. {
  181. m_ViewStart+=Dist;
  182. m_ViewEnd+=Dist;
  183. }
  184. }
  185. DragX=xx;
  186. DragY=yy;
  187. }
  188. if (Mousebutton==3)
  189. {
  190. // only draw wave at 1 pixel = 1 sample
  191. if ((m_ViewEnd-m_ViewStart)/w()==1)
  192. {
  193. int MousePos=(xx-x())*((m_ViewEnd-m_ViewStart)/w())+m_ViewStart;
  194. float Value=-(yy-y())/((float)h()/2.0f)+1.0f;
  195. m_Sample->Set(MousePos,Value);
  196. redraw();
  197. }
  198. }
  199. do_callback();
  200. redraw();
  201. }
  202. if (m_EndPos>=m_Sample->GetLength()) m_EndPos=m_Sample->GetLength()-1;
  203. return 1;
  204. }
  205. void Fl_WaveDisplay::ZoomIn()
  206. {
  207. int Zoom=(int)((m_ViewEnd-m_ViewStart)*0.03f);
  208. if ((m_ViewEnd-m_ViewStart)/w()>1)
  209. {
  210. m_ViewStart+=Zoom;
  211. m_ViewEnd-=Zoom;
  212. }
  213. redraw();
  214. }
  215. void Fl_WaveDisplay::ZoomOut()
  216. {
  217. int Zoom=(int)((m_ViewEnd-m_ViewStart)*0.03f);
  218. m_ViewStart-=Zoom;
  219. m_ViewEnd+=Zoom;
  220. redraw();
  221. }
  222. ////////////////////////////////////////////
  223. PoshSamplerPluginGUI::PoshSamplerPluginGUI(int w, int h,PoshSamplerPlugin *o,ChannelHandler *ch,const HostInfo *Info) :
  224. SpiralPluginGUI(w,h,o,ch),
  225. m_UpdateMe(false)
  226. {
  227. int n=0;
  228. m_Load = new Fl_Button(5, 20, 70, 20, "Load");
  229. m_Load->labelsize(10);
  230. m_Load->box (FL_PLASTIC_UP_BOX);
  231. m_Load->color (Info->GUI_COLOUR);
  232. m_Load->selection_color (Info->GUI_COLOUR);
  233. m_Load->callback((Fl_Callback*)cb_Load);
  234. add(m_Load);
  235. m_Save = new Fl_Button(5, 40, 70, 20, "Save");
  236. m_Save->labelsize(10);
  237. m_Save->box (FL_PLASTIC_UP_BOX);
  238. m_Save->color (Info->GUI_COLOUR);
  239. m_Save->selection_color (Info->GUI_COLOUR);
  240. m_Save->callback((Fl_Callback*)cb_Save);
  241. add(m_Save);
  242. m_Record = new Fl_Button(5, 60, 70, 20, "Record");
  243. m_Record->type (FL_TOGGLE_BUTTON);
  244. m_Record->box (FL_PLASTIC_UP_BOX);
  245. m_Record->color (FL_RED);
  246. m_Record->selection_color (FL_RED);
  247. m_Record->labelsize (10);
  248. //m_Record->labelcolor (FL_RED);
  249. m_Record->callback((Fl_Callback*)cb_Record);
  250. add(m_Record);
  251. m_Loop = new Fl_Button(80, 20, 70, 20, "Loop");
  252. m_Loop->type (FL_TOGGLE_BUTTON);
  253. m_Loop->labelsize(10);
  254. m_Loop->box (FL_PLASTIC_UP_BOX);
  255. m_Loop->color (Info->GUI_COLOUR);
  256. m_Loop->selection_color (Info->GUI_COLOUR);
  257. m_Loop->callback((Fl_Callback*)cb_Loop);
  258. add(m_Loop);
  259. m_PingPong = new Fl_Button(80, 40, 70, 20, "PingPong");
  260. m_PingPong->labelsize(10);
  261. m_PingPong->type (FL_TOGGLE_BUTTON);
  262. m_PingPong->labelsize(10);
  263. m_PingPong->box (FL_PLASTIC_UP_BOX);
  264. m_PingPong->color (Info->GUI_COLOUR);
  265. m_PingPong->selection_color (Info->GUI_COLOUR);
  266. m_PingPong->callback((Fl_Callback*)cb_PingPong);
  267. add(m_PingPong);
  268. m_PosMarker = new Fl_Button(80, 60, 70, 20, "PosMarker");
  269. m_PosMarker->labelsize(10);
  270. m_PosMarker->type (FL_TOGGLE_BUTTON);
  271. m_PosMarker->labelsize(10);
  272. m_PosMarker->box (FL_PLASTIC_UP_BOX);
  273. m_PosMarker->color (Info->GUI_COLOUR);
  274. m_PosMarker->selection_color (Info->GUI_COLOUR);
  275. m_PosMarker->value(1);
  276. m_PosMarker->callback((Fl_Callback*)cb_PosMarker);
  277. add(m_PosMarker);
  278. m_Volume = new Fl_Knob(160, 20, 50, 50, "Volume");
  279. m_Volume->color(Info->GUI_COLOUR);
  280. m_Volume->type(Fl_Knob::LINELIN);
  281. m_Volume->labelsize(10);
  282. m_Volume->maximum(2);
  283. m_Volume->step(0.001);
  284. m_Volume->value(1);
  285. m_Volume->callback((Fl_Callback*)cb_Volume);
  286. add(m_Volume);
  287. m_Pitch = new Fl_Knob(220, 20, 50, 50, "Pitch");
  288. m_Pitch->color(Info->GUI_COLOUR);
  289. m_Pitch->type(Fl_Knob::LINELIN);
  290. m_Pitch->labelsize(10);
  291. m_Pitch->maximum(10);
  292. m_Pitch->step(0.001);
  293. m_Pitch->value(1);
  294. m_Pitch->callback((Fl_Callback*)cb_Pitch);
  295. add(m_Pitch);
  296. m_Octave = new Fl_Knob(280, 20, 50, 50, "Octave");
  297. m_Octave->color(Info->GUI_COLOUR);
  298. m_Octave->type(Fl_Knob::LINELIN);
  299. m_Octave->labelsize(10);
  300. m_Octave->maximum(12);
  301. m_Octave->step(1);
  302. m_Octave->value(6);
  303. m_Octave->callback((Fl_Callback*)cb_Octave);
  304. add(m_Octave);
  305. m_SampleNum = new Fl_Counter (w-60, 15, 45, 20, "Sample");
  306. m_SampleNum->labelsize(10);
  307. m_SampleNum->type(FL_SIMPLE_COUNTER);
  308. m_SampleNum->box (FL_PLASTIC_UP_BOX);
  309. m_SampleNum->color (Info->GUI_COLOUR);
  310. m_SampleNum->selection_color (Info->GUI_COLOUR);
  311. m_SampleNum->step(1);
  312. m_SampleNum->value(n);
  313. m_SampleNum->callback((Fl_Callback*)cb_SampleNum);
  314. add(m_SampleNum);
  315. m_Note = new Fl_Counter (w-60, 50, 45, 20, "Trig Note");
  316. m_Note->labelsize(10);
  317. m_Note->type(FL_SIMPLE_COUNTER);
  318. m_Note->box (FL_PLASTIC_UP_BOX);
  319. m_Note->color (Info->GUI_COLOUR);
  320. m_Note->selection_color (Info->GUI_COLOUR);
  321. m_Note->step(1);
  322. m_Note->value(n);
  323. m_Note->callback((Fl_Callback*)cb_Note);
  324. add(m_Note);
  325. m_Display = new Fl_WaveDisplay(5,85,w-10,100,"");
  326. m_Display->SetColours (Info->SCOPE_BG_COLOUR, Info->SCOPE_FG_COLOUR,
  327. Info->SCOPE_SEL_COLOUR, Info->SCOPE_IND_COLOUR, Info->SCOPE_MRK_COLOUR);
  328. m_Display->callback((Fl_Callback*)cb_WaveDisplay);
  329. int bx=5,by=190,bw=w/9-2,bh=20,bs=w/9-2;
  330. n=0;
  331. m_Cut = new Fl_Button(bx+(n++*bs),by,bw,bh,"Cut");
  332. m_Cut->labelsize(10);
  333. m_Cut->box (FL_PLASTIC_UP_BOX);
  334. m_Cut->color (Info->GUI_COLOUR);
  335. m_Cut->selection_color (Info->GUI_COLOUR);
  336. m_Cut->callback((Fl_Callback*)cb_Cut);
  337. m_Copy = new Fl_Button(bx+(n++*bs),by,bw,bh,"Copy");
  338. m_Copy->labelsize(10);
  339. m_Copy->box (FL_PLASTIC_UP_BOX);
  340. m_Copy->color (Info->GUI_COLOUR);
  341. m_Copy->selection_color (Info->GUI_COLOUR);
  342. m_Copy->callback((Fl_Callback*)cb_Copy);
  343. m_Paste = new Fl_Button(bx+(n++*bs),by,bw,bh,"Paste");
  344. m_Paste->labelsize(10);
  345. m_Paste->box (FL_PLASTIC_UP_BOX);
  346. m_Paste->color (Info->GUI_COLOUR);
  347. m_Paste->selection_color (Info->GUI_COLOUR);
  348. m_Paste->callback((Fl_Callback*)cb_Paste);
  349. m_Mix = new Fl_Button(bx+(n++*bs),by,bw,bh,"Mix");
  350. m_Mix->labelsize(10);
  351. m_Mix->box (FL_PLASTIC_UP_BOX);
  352. m_Mix->color (Info->GUI_COLOUR);
  353. m_Mix->selection_color (Info->GUI_COLOUR);
  354. m_Mix->callback((Fl_Callback*)cb_Mix);
  355. m_Crop = new Fl_Button(bx+(n++*bs),by,bw,bh,"Crop");
  356. m_Crop->labelsize(10);
  357. m_Crop->box (FL_PLASTIC_UP_BOX);
  358. m_Crop->color (Info->GUI_COLOUR);
  359. m_Crop->selection_color (Info->GUI_COLOUR);
  360. m_Crop->callback((Fl_Callback*)cb_Crop);
  361. m_Reverse = new Fl_Button(bx+(n++*bs),by,bw,bh,"Reverse");
  362. m_Reverse->labelsize(10);
  363. m_Reverse->box (FL_PLASTIC_UP_BOX);
  364. m_Reverse->color (Info->GUI_COLOUR);
  365. m_Reverse->selection_color (Info->GUI_COLOUR);
  366. m_Reverse->callback((Fl_Callback*)cb_Reverse);
  367. m_Amp = new Fl_Button(bx+(n++*bs),by,bw,bh,"Amp");
  368. m_Amp->labelsize(10);
  369. m_Amp->box (FL_PLASTIC_UP_BOX);
  370. m_Amp->color (Info->GUI_COLOUR);
  371. m_Amp->selection_color (Info->GUI_COLOUR);
  372. m_Amp->callback((Fl_Callback*)cb_Amp);
  373. m_ZoomIn = new Fl_Button(bx+(n++*bs),by,bw,bh,"Zoom +");
  374. m_ZoomIn->labelsize(10);
  375. m_ZoomIn->box (FL_PLASTIC_UP_BOX);
  376. m_ZoomIn->color (Info->GUI_COLOUR);
  377. m_ZoomIn->selection_color (Info->GUI_COLOUR);
  378. //m_ZoomIn->callback((Fl_Callback*)cb_ZoomIn);
  379. m_ZoomOut = new Fl_Button(bx+(n++*bs),by,bw,bh,"Zoom -");
  380. m_ZoomOut->labelsize(10);
  381. m_ZoomOut->box (FL_PLASTIC_UP_BOX);
  382. m_ZoomOut->color (Info->GUI_COLOUR);
  383. m_ZoomOut->selection_color (Info->GUI_COLOUR);
  384. //m_ZoomOut->callback((Fl_Callback*)cb_ZoomOut);
  385. end();
  386. redraw();
  387. }
  388. void PoshSamplerPluginGUI::UpdateSampleDisplay(int num)
  389. {
  390. m_GUICH->SetCommand(PoshSamplerPlugin::GETSAMPLE);
  391. m_GUICH->Wait();
  392. m_GUICH->RequestChannelAndWait("SampleSize");
  393. long SampleSize=m_GUICH->GetLong("SampleSize");
  394. if (SampleSize)
  395. {
  396. char *TempBuf = new char[SampleSize];
  397. m_GUICH->BulkTransfer("SampleBuffer",(void*)TempBuf,SampleSize);
  398. m_Display->SetSample((float*)TempBuf,SampleSize/sizeof(float));
  399. delete[] TempBuf;
  400. }
  401. }
  402. void PoshSamplerPluginGUI::Update()
  403. {
  404. SetPlayPos(m_GUICH->GetLong("PlayPos"));
  405. if (m_ZoomIn->value()) m_Display->ZoomIn();
  406. if (m_ZoomOut->value()) m_Display->ZoomOut();
  407. if (m_UpdateMe)
  408. {
  409. UpdateSampleDisplay((int)m_SampleNum->value());
  410. m_Display->redraw();
  411. m_UpdateMe=false;
  412. }
  413. //redraw();
  414. }
  415. void PoshSamplerPluginGUI::UpdateValues(SpiralPlugin *o)
  416. {
  417. PoshSamplerPlugin *Plugin = (PoshSamplerPlugin*)o;
  418. m_Volume->value(Plugin->GetVolume((int)m_SampleNum->value()));
  419. m_Pitch->value(Plugin->GetPitch((int)m_SampleNum->value()));
  420. m_Note->value(Plugin->GetNote((int)m_SampleNum->value()));
  421. m_Loop->value(Plugin->GetLoop((int)m_SampleNum->value()));
  422. m_UpdateMe=true;
  423. m_Display->SetPlayStart(Plugin->GetPlayStart((int)m_SampleNum->value()));
  424. m_Display->SetLoopStart(Plugin->GetLoopStart((int)m_SampleNum->value()));
  425. m_Display->SetLoopEnd(Plugin->GetLoopEnd((int)m_SampleNum->value()));
  426. m_Display->redraw();
  427. }
  428. inline void PoshSamplerPluginGUI::cb_Load_i(Fl_Button* o, void* v)
  429. {
  430. char *fn=fl_file_chooser("Load a sample", "{*.wav,*.WAV}", NULL);
  431. if (fn && fn!='\0')
  432. {
  433. strcpy(m_TextBuf,fn);
  434. m_GUICH->SetData("Name",m_TextBuf);
  435. m_GUICH->Set("Num",(int)m_SampleNum->value());
  436. m_GUICH->SetCommand(PoshSamplerPlugin::LOAD);
  437. m_GUICH->Wait(); // wait for the sample to load
  438. UpdateSampleDisplay((int)m_SampleNum->value());
  439. m_Display->redraw();
  440. redraw();
  441. }
  442. }
  443. void PoshSamplerPluginGUI::cb_Load(Fl_Button* o, void* v)
  444. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Load_i(o,v);}
  445. inline void PoshSamplerPluginGUI::cb_Save_i(Fl_Button* o, void* v)
  446. {
  447. char *fn=fl_file_chooser("Save sample", "{*.wav,*.WAV}", NULL);
  448. if (fn && fn!='\0')
  449. {
  450. strcpy(m_TextBuf,fn);
  451. m_GUICH->Set("Name",m_TextBuf);
  452. m_GUICH->Set("Num",(int)m_SampleNum->value());
  453. m_GUICH->SetCommand(PoshSamplerPlugin::SAVE);
  454. }
  455. }
  456. void PoshSamplerPluginGUI::cb_Save(Fl_Button* o, void* v)
  457. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Save_i(o,v);}
  458. inline void PoshSamplerPluginGUI::cb_Volume_i(Fl_Knob* o, void* v)
  459. {
  460. m_GUICH->Set("Value",(float)o->value());
  461. m_GUICH->Set("Num",(int)m_SampleNum->value());
  462. m_GUICH->SetCommand(PoshSamplerPlugin::SETVOL);
  463. }
  464. void PoshSamplerPluginGUI::cb_Volume(Fl_Knob* o, void* v)
  465. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Volume_i(o,v);}
  466. inline void PoshSamplerPluginGUI::cb_Pitch_i(Fl_Knob* o, void* v)
  467. {
  468. m_GUICH->Set("Value",(float)o->value());
  469. m_GUICH->Set("Num",(int)m_SampleNum->value());
  470. m_GUICH->SetCommand(PoshSamplerPlugin::SETPITCH);
  471. }
  472. void PoshSamplerPluginGUI::cb_Pitch(Fl_Knob* o, void* v)
  473. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Pitch_i(o,v);}
  474. inline void PoshSamplerPluginGUI::cb_Octave_i(Fl_Knob* o, void* v)
  475. {
  476. m_GUICH->Set("Int",(int)o->value());
  477. m_GUICH->Set("Num",(int)m_SampleNum->value());
  478. m_GUICH->SetCommand(PoshSamplerPlugin::SETOCT);
  479. }
  480. void PoshSamplerPluginGUI::cb_Octave(Fl_Knob* o, void* v)
  481. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Octave_i(o,v);}
  482. inline void PoshSamplerPluginGUI::cb_Loop_i(Fl_Button* o, void* v)
  483. {
  484. m_GUICH->Set("Bool",(bool)o->value());
  485. m_GUICH->Set("Num",(int)m_SampleNum->value());
  486. m_GUICH->SetCommand(PoshSamplerPlugin::SETLOOP);
  487. }
  488. void PoshSamplerPluginGUI::cb_Loop(Fl_Button* o, void* v)
  489. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Loop_i(o,v);}
  490. inline void PoshSamplerPluginGUI::cb_PingPong_i(Fl_Button* o, void* v)
  491. {
  492. m_GUICH->Set("Bool",(bool)o->value());
  493. m_GUICH->Set("Num",(int)m_SampleNum->value());
  494. m_GUICH->SetCommand(PoshSamplerPlugin::SETPING);
  495. }
  496. void PoshSamplerPluginGUI::cb_PingPong(Fl_Button* o, void* v)
  497. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_PingPong_i(o,v);}
  498. inline void PoshSamplerPluginGUI::cb_Record_i(Fl_Button* o, void* v)
  499. {
  500. m_GUICH->Set("Bool",(bool)o->value());
  501. m_GUICH->SetCommand(PoshSamplerPlugin::SETREC);
  502. redraw();
  503. }
  504. void PoshSamplerPluginGUI::cb_Record(Fl_Button* o, void* v)
  505. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Record_i(o,v);}
  506. inline void PoshSamplerPluginGUI::cb_PosMarker_i(Fl_Button* o, void* v)
  507. { m_Display->SetPosMarker(o->value()); }
  508. void PoshSamplerPluginGUI::cb_PosMarker(Fl_Button* o, void* v)
  509. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_PosMarker_i(o,v);}
  510. inline void PoshSamplerPluginGUI::cb_Note_i(Fl_Counter* o, void* v)
  511. {
  512. m_GUICH->Set("Int",(int)o->value());
  513. m_GUICH->Set("Num",(int)m_SampleNum->value());
  514. m_GUICH->SetCommand(PoshSamplerPlugin::SETNOTE);
  515. }
  516. void PoshSamplerPluginGUI::cb_Note(Fl_Counter* o, void* v)
  517. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Note_i(o,v);}
  518. inline void PoshSamplerPluginGUI::cb_SampleNum_i(Fl_Counter* o, void* v)
  519. {
  520. if (m_SampleNum->value()<0) m_SampleNum->value(0);
  521. if (m_SampleNum->value()>7) m_SampleNum->value(7);
  522. m_GUICH->Set("Num",(int)m_SampleNum->value());
  523. m_GUICH->SetCommand(PoshSamplerPlugin::SETCURRENT);
  524. m_GUICH->Wait();
  525. UpdateSampleDisplay((int)m_SampleNum->value());
  526. }
  527. void PoshSamplerPluginGUI::cb_SampleNum(Fl_Counter* o, void* v)
  528. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_SampleNum_i(o,v);}
  529. inline void PoshSamplerPluginGUI::cb_Cut_i(Fl_Button* o, void* v)
  530. {
  531. m_GUICH->Set("Start",(long)m_Display->GetRangeStart());
  532. m_GUICH->Set("End",(long)m_Display->GetRangeEnd());
  533. m_GUICH->Set("Num",(int)m_SampleNum->value());
  534. m_GUICH->SetCommand(PoshSamplerPlugin::CUT);
  535. m_GUICH->Wait();
  536. UpdateSampleDisplay((int)m_SampleNum->value());
  537. m_Display->redraw();
  538. }
  539. void PoshSamplerPluginGUI::cb_Cut(Fl_Button* o, void* v)
  540. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Cut_i(o,v);}
  541. inline void PoshSamplerPluginGUI::cb_Copy_i(Fl_Button* o, void* v)
  542. {
  543. m_GUICH->Set("Start",(long)m_Display->GetRangeStart());
  544. m_GUICH->Set("End",(long)m_Display->GetRangeEnd());
  545. m_GUICH->Set("Num",(int)m_SampleNum->value());
  546. m_GUICH->SetCommand(PoshSamplerPlugin::COPY);
  547. }
  548. void PoshSamplerPluginGUI::cb_Copy(Fl_Button* o, void* v)
  549. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Copy_i(o,v);}
  550. inline void PoshSamplerPluginGUI::cb_Paste_i(Fl_Button* o, void* v)
  551. {
  552. m_GUICH->Set("Start",(long)m_Display->GetRangeStart());
  553. m_GUICH->Set("End",(long)m_Display->GetRangeEnd());
  554. m_GUICH->Set("Num",(int)m_SampleNum->value());
  555. m_GUICH->SetCommand(PoshSamplerPlugin::PASTE);
  556. m_GUICH->Wait();
  557. UpdateSampleDisplay((int)m_SampleNum->value());
  558. m_Display->redraw();
  559. }
  560. void PoshSamplerPluginGUI::cb_Paste(Fl_Button* o, void* v)
  561. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Paste_i(o,v);}
  562. inline void PoshSamplerPluginGUI::cb_Mix_i(Fl_Button* o, void* v)
  563. {
  564. m_GUICH->Set("Start",(long)m_Display->GetRangeStart());
  565. m_GUICH->Set("End",(long)m_Display->GetRangeEnd());
  566. m_GUICH->Set("Num",(int)m_SampleNum->value());
  567. m_GUICH->SetCommand(PoshSamplerPlugin::MIX);
  568. m_GUICH->Wait();
  569. UpdateSampleDisplay((int)m_SampleNum->value());
  570. m_Display->redraw();
  571. }
  572. void PoshSamplerPluginGUI::cb_Mix(Fl_Button* o, void* v)
  573. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Mix_i(o,v);}
  574. inline void PoshSamplerPluginGUI::cb_Crop_i(Fl_Button* o, void* v)
  575. {
  576. m_GUICH->Set("Start",(long)m_Display->GetRangeStart());
  577. m_GUICH->Set("End",(long)m_Display->GetRangeEnd());
  578. m_GUICH->Set("Num",(int)m_SampleNum->value());
  579. m_GUICH->SetCommand(PoshSamplerPlugin::CROP);
  580. m_GUICH->Wait();
  581. UpdateSampleDisplay((int)m_SampleNum->value());
  582. m_Display->redraw();
  583. }
  584. void PoshSamplerPluginGUI::cb_Crop(Fl_Button* o, void* v)
  585. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Crop_i(o,v);}
  586. inline void PoshSamplerPluginGUI::cb_Reverse_i(Fl_Button* o, void* v)
  587. {
  588. m_GUICH->Set("Start",(long)m_Display->GetRangeStart());
  589. m_GUICH->Set("End",(long)m_Display->GetRangeEnd());
  590. m_GUICH->Set("Num",(int)m_SampleNum->value());
  591. m_GUICH->SetCommand(PoshSamplerPlugin::REV);
  592. m_GUICH->Wait();
  593. UpdateSampleDisplay((int)m_SampleNum->value());
  594. m_Display->redraw();
  595. }
  596. void PoshSamplerPluginGUI::cb_Reverse(Fl_Button* o, void* v)
  597. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Reverse_i(o,v);}
  598. inline void PoshSamplerPluginGUI::cb_Amp_i(Fl_Button* o, void* v)
  599. {
  600. m_GUICH->Set("Start",(long)m_Display->GetRangeStart());
  601. m_GUICH->Set("End",(long)m_Display->GetRangeEnd());
  602. m_GUICH->Set("Num",(int)m_SampleNum->value());
  603. m_GUICH->SetCommand(PoshSamplerPlugin::AMP);
  604. m_GUICH->Wait();
  605. UpdateSampleDisplay((int)m_SampleNum->value());
  606. m_Display->redraw();
  607. }
  608. void PoshSamplerPluginGUI::cb_Amp(Fl_Button* o, void* v)
  609. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Amp_i(o,v);}
  610. inline void PoshSamplerPluginGUI::cb_WaveDisplay_i(Fl_WaveDisplay* o, void* v)
  611. {
  612. m_GUICH->Set("Start",(long)o->GetPlayStart());
  613. m_GUICH->Set("End",(long)o->GetLoopEnd());
  614. m_GUICH->Set("LoopStart",(long)o->GetLoopStart());
  615. m_GUICH->Set("Num",(int)m_SampleNum->value());
  616. m_GUICH->SetCommand(PoshSamplerPlugin::SETPLAYPOINTS);
  617. }
  618. void PoshSamplerPluginGUI::cb_WaveDisplay(Fl_WaveDisplay* o, void* v)
  619. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_WaveDisplay_i(o,v);}
  620. inline void PoshSamplerPluginGUI::cb_ZoomIn_i(Fl_Button* o, void* v)
  621. {
  622. m_Display->ZoomIn();
  623. }
  624. void PoshSamplerPluginGUI::cb_ZoomIn(Fl_Button* o, void* v)
  625. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_ZoomIn_i(o,v);}
  626. inline void PoshSamplerPluginGUI::cb_ZoomOut_i(Fl_Button* o, void* v)
  627. {
  628. m_Display->ZoomOut();
  629. }
  630. void PoshSamplerPluginGUI::cb_ZoomOut(Fl_Button* o, void* v)
  631. { ((PoshSamplerPluginGUI*)(o->parent()))->cb_ZoomOut_i(o,v);}
  632. const string PoshSamplerPluginGUI::GetHelpText(const string &loc){
  633. return string("")
  634. + "A sampler that allows simple sample editing (cut copy paste etc),\n"
  635. + "dirty time stretching (by modulating the start pos + retriggering +\n"
  636. + "modulating pitch) and loop start/end points with ping pong loop mode.\n"
  637. + "Also implementations of controls, such as continuous pitch changing,\n"
  638. + "so you can add portmento to samples, trigger velocity sets sample\n"
  639. + "volume.\n\n"
  640. + "Can records input data too.\n\n"
  641. + "Controls:\n"
  642. + "lmb: Select region\n"
  643. + "mmb: Move view\n"
  644. + "rmb: Draws samples at full zoom.\n\n"
  645. + "Left mouse also drags loop points. The Loop end marker defaults to the\n"
  646. + "end of the sample.\n\n"
  647. + "Note: The loading and saving of samples is not yet realtime safe";
  648. }