gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
WSOLAJackGTK.C
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream 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  GTK+ IOStream 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 have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 #include "WSOLA.H"
18 #ifndef _MSC_VER
19 #include "Sox.H"
20 #else
21 // Note : Microsoft doesn't understand the different between upper and lower case in file names.
22 // on microsoft, you have to manually rename Sox.H to SoxWindows.H
23 #include "SoxWindows.H"
24 #endif
25 
26 
27 #include <OptionParser.H>
28 #include <Window.H>
29 #include <Buttons.H>
30 #include <Scales.H>
31 #include <Box.H>
32 
33 #include "WSOLAJack.H"
34 
35 #include <sstream>
36 
37 void printUsage(const char *str) {
38  cerr<<"Usage: "<<str<<" -h or --help"<<endl;
39  cerr<<"Usage: "<<str<<" fileName.wav"<<endl;
40  cerr<<"\t the fileName can be any readable audio file format."<<endl;
41  cerr<<"\n Author : Matt Flax <flatmax@>"<<endl;
42  exit(0);
43 }
44 
45 static void scaleTouch(void *widget, gpointer data) {
46  WSOLAJack *wsj=reinterpret_cast<WSOLAJack *>(data);
47  FP_TYPE newScale=Scales().getVal((GtkRange*)widget);
48  wsj->setTimeScale(newScale);
49 }
50 
51 static void quit(void *wid, gpointer data) {
52  gtk_main_quit();
53 }
54 
55 int main(int argc, char *argv[]) {
56  if (argc<2)
57  printUsage(argv[0]);
58 
59  OptionParser op;
60  int i=0;
61  string help;
62  if (op.getArg<string>("h", argc, argv, help, i=0)!=0)
63  printUsage(argv[0]);
64  if (op.getArg<string>("help", argc, argv, help, i=0)!=0)
65  printUsage(argv[0]);
66 
67  string fileName(argv[argc-1]);
68  cout<<"input file = "<<fileName<<endl;
69 
70  WSOLAJack WSOLAjack(fileName);
71 
72  gtk_init( &argc, &argv );
73  Window topWindow;
74 
75  Scales speed;
76  speed<<VScaleFuncData(.7,1.51,.01,scaleTouch,&WSOLAjack);
77  speed=1.;
78  topWindow<< (VBox()
79  <<BoxIS(true,true,true) <<speed // the speed scale
80  <<BoxIS(false,false,true) <<(Buttons()<<BUTTONLABELSTRUCT("Quit", quit, NULL))
81  ).show();
82 
83  gtk_main();
84 
85  return NO_ERROR;
86 }
87 
88 
float FP_TYPE
Definition: audioMasker.C:25
int getArg(string key, int argc, char *argv[], TYPE &ret, int i)
Definition: OptionParser.H:43
static void quit(void *wid, gpointer data)
Definition: WSOLAJackGTK.C:51
void setTimeScale(FP_TYPE ts)
Definition: WSOLAJack.H:159
Definition: Box.H:351
Definition: Window.H:26
int main(int argc, char *argv[])
Definition: WSOLAJackGTK.C:55
#define BUTTONLABELSTRUCT(s, f, d)
Definition: Buttons.H:73
#define NO_ERROR
There is no error.
Definition: Debug.H:33
GtkWidget * show(void)
Definition: Widget.H:65
void printUsage(const char *str)
Definition: WSOLAJackGTK.C:37
Definition: Scales.H:159
Class to setup buttons whic are either text, image or toggle types. Buttons are defined in terms of t...
Definition: Buttons.H:184
static double getVal(GtkRange *wid)
Definition: Scales.H:198
Definition: Box.H:33
static void scaleTouch(void *widget, gpointer data)
Definition: WSOLAJackGTK.C:45
gtkIOStream: /tmp/gtkiostream/applications/WSOLAJackGTK.C Source File
GTK+ IOStream  Beta