File: ecaconvert.cpp

package info (click to toggle)
ecasound 2.9.3-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 6,292 kB
  • sloc: cpp: 39,475; sh: 4,335; lisp: 1,918; ansic: 1,883; makefile: 888; python: 617; ruby: 202
file content (117 lines) | stat: -rw-r--r-- 3,165 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// ------------------------------------------------------------------------
// ecaconvert.cpp: A simple command-line tool for converting
//                 audio files.
// Copyright (C) 2000,2002,2005-2006 Kai Vehmanen
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
// ------------------------------------------------------------------------

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <iostream>
#include <string>
#include <cstdio>

#include <kvutils/kvu_com_line.h>
#include <kvutils/kvu_numtostr.h>

#include <eca-control-interface.h>

#include "ecicpp_helpers.h"

/**
 * Function declarations
 */

int main(int argc, char *argv[]);
void print_usage(void);

using std::cerr;
using std::cout;
using std::endl;
using std::string;

static const string ecatools_play_version = "20050316-18";

int main(int argc, char *argv[])
{
  COMMAND_LINE cline = COMMAND_LINE (argc, argv);

  if (cline.size() < 2) {
    print_usage();
    return(1);
  }

  string filename;

  ECA_CONTROL_INTERFACE eci;

  cline.begin();
  cline.next(); // skip the program name
  
  string extension (".raw");
  if (cline.end() != true) {
    extension = cline.current();
    cline.next();
  }
  
  while(cline.end() != true) {
    filename = cline.current();
    
    cout << "Converting file \"" << filename << "\" --> ";
    cout << "\"" << filename + extension << "\"." << endl;
    
    eci.command("cs-add default");
    eci.command("c-add default");

    string format;
    if (ecicpp_add_file_input(&eci, filename, &format) < 0) break;
    
    cout << "Using audio format -f:" << format << "\n";

    if (ecicpp_add_output(&eci, filename + extension, format) < 0) break;

    if (ecicpp_connect_chainsetup(&eci, "default") < 0) {
      break;
    }
    
    cout << "Starting processing...\n";
    
    // blocks until processing is done
    eci.command("run");
    
    cout << "Processing finished.\n";
    
    eci.command("cs-disconnect");
    eci.command("cs-select default");
    eci.command("cs-remove");
    
    cline.next();
  }

  return(0);
}

void print_usage(void)
{
  cerr << "****************************************************************************\n";
  cerr << "* ecaconvert, v" << ecatools_play_version << " (" << VERSION << ")\n";
  cerr << "* (C) 2000-2004 Kai Vehmanen, released under GPL licence \n";
  cerr << "****************************************************************************\n";

  cerr << "\nUSAGE: ecaconvert .extension file1 [ file2, ... fileN ]\n\n";
}