/[svn]/libgig/trunk/src/tools/gigmerge.cpp
ViewVC logotype

Annotation of /libgig/trunk/src/tools/gigmerge.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2573 - (hide annotations) (download)
Thu May 22 15:17:09 2014 UTC (9 years, 11 months ago) by schoenebeck
File size: 4837 byte(s)
* Akai: Fixed Mac OSX support so that the Akai lib files and tools
  compile without any exotic third party libraries.

1 schoenebeck 2482 /***************************************************************************
2     * *
3     * libgig - C++ cross-platform Gigasampler format file access library *
4     * *
5 schoenebeck 2573 * Copyright (C) 2003-2014 by Christian Schoenebeck *
6 schoenebeck 2482 * <cuse@users.sourceforge.net> *
7     * *
8     * This program is part of libgig. *
9     * *
10     * This program is free software; you can redistribute it and/or modify *
11     * it under the terms of the GNU General Public License as published by *
12     * the Free Software Foundation; either version 2 of the License, or *
13     * (at your option) any later version. *
14     * *
15     * This program is distributed in the hope that it will be useful, *
16     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18     * GNU General Public License for more details. *
19     * *
20     * You should have received a copy of the GNU General Public License *
21     * along with this program; if not, write to the Free Software *
22     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
23     * MA 02111-1307 USA *
24     ***************************************************************************/
25    
26     #ifdef HAVE_CONFIG_H
27     # include <config.h>
28     #endif
29    
30     #include <iostream>
31     #include <cstdlib>
32     #include <string>
33     #include <vector>
34    
35 schoenebeck 2573 #include "../gig.h"
36 schoenebeck 2482
37     using namespace std;
38    
39     static vector<RIFF::File*> g_riffs;
40     static vector<gig::File*> g_gigs;
41    
42     static void printUsage() {
43     cout << "gigmerge - merges several Gigasampler files to one Gigasampler file." << endl;
44     cout << endl;
45     cout << "Usage: gigmerge [-v] FILE1 FILE2 [ ... ] NEWFILE" << endl;
46     cout << endl;
47     cout << " -v Print version and exit." << endl;
48     cout << endl;
49     cout << "Note: There is no check for duplicate (equivalent) samples yet." << endl;
50     cout << endl;
51     }
52    
53     static string programRevision() {
54 schoenebeck 2493 string s = "$Revision$";
55 schoenebeck 2482 return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
56     }
57    
58     static void printVersion() {
59     cout << "gigmerge revision " << programRevision() << endl;
60     cout << "using " << gig::libraryName() << " " << gig::libraryVersion() << endl;
61     }
62    
63     static void cleanup() {
64     for (int i = 0; i < g_gigs.size(); ++i) delete g_gigs[i];
65     for (int i = 0; i < g_riffs.size(); ++i) delete g_riffs[i];
66     g_gigs.clear();
67     g_riffs.clear();
68     }
69    
70     int main(int argc, char *argv[]) {
71     // validate arguments provided to this program
72     if (argc <= 1) {
73     printUsage();
74     return EXIT_FAILURE;
75     }
76     if (argv[1][0] == '-') {
77     switch (argv[1][1]) {
78     case 'v':
79     printVersion();
80     return EXIT_SUCCESS;
81     }
82     }
83     if (argc <= 3) {
84     printUsage();
85     return EXIT_FAILURE;
86     }
87    
88     // open all input .gig files
89     const int iInputFiles = argc - 2;
90     int i;
91     try {
92     for (i = 0; i < iInputFiles; ++i) {
93     RIFF::File* riff = new RIFF::File(argv[i+1]);
94     g_riffs.push_back(riff);
95    
96     gig::File* gig = new gig::File(riff);
97     g_gigs.push_back(gig);
98     }
99     } catch (RIFF::Exception e) {
100     cerr << "Failed opening input file " << (i+1) << endl;
101     e.PrintMessage();
102     return EXIT_FAILURE;
103     } catch (...) {
104     cerr << "Failed opening input file " << (i+1) << endl;
105     cerr << "Unknown exception while trying to access input file." << endl;
106     return EXIT_FAILURE;
107     }
108    
109     gig::File* outGig = NULL;
110    
111     // create a new .gig file as output
112     try {
113     outGig = new gig::File();
114     outGig->SetFileName(argv[argc-1]); // required, because AddContentOf() performs auto save
115     for (int i = 0; i < g_gigs.size(); ++i) {
116     outGig->AddContentOf(g_gigs[i]);
117     }
118     outGig->Save();
119     } catch (RIFF::Exception e) {
120     cerr << "Failed generating output file:" << endl;
121     e.PrintMessage();
122     return EXIT_FAILURE;
123     } catch (...) {
124     cerr << "Unknown exception while trying to assemble output file." << endl;
125     return EXIT_FAILURE;
126     }
127    
128     // close all input files
129     cleanup();
130    
131     return EXIT_SUCCESS;
132     }

Properties

Name Value
svn:keywords Revision

  ViewVC Help
Powered by ViewVC