File: resampler.cs

package info (click to toggle)
cadencii 3.3.9%2Bsvn20110818.r1732-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 35,764 kB
  • ctags: 26,929
  • sloc: cs: 160,836; java: 42,449; cpp: 7,605; ansic: 1,728; perl: 1,087; makefile: 236; php: 142; xml: 117; sh: 21
file content (65 lines) | stat: -rw-r--r-- 2,560 bytes parent folder | download | duplicates (6)
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
using System;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;

class Resampler{
    public static void Main( string[] args ){
        string arg = "";
        foreach( string s in args ){
            arg += "\"" + s + "\" ";
        }
        string exe = Environment.GetCommandLineArgs()[0];
        string exe_name = Path.GetFileNameWithoutExtension( exe );
        string path = Application.StartupPath;
        if( exe_name == "resampler" && args.Length >= 12 ){
            string outpath = args[1];
            string out_name = Path.GetFileNameWithoutExtension( outpath );
            string out_dir = Path.GetDirectoryName( outpath );
            string logname = Path.Combine( out_dir, out_name + ".log" );
            using( StreamWriter sw = new StreamWriter( logname ) ){
                const int PBTYPE = 5;
                int indx_q = args[11].IndexOf( "Q" );
                int count = 0;
                if( indx_q > 0 ){
                    string pit = args[11].Substring( 0, indx_q );
                    if( args[11].Length >= indx_q + 1 ){
                        string tempo = args[11].Substring( indx_q + 1 );
                        sw.WriteLine( "# " + tempo );
                    }
                    sw.WriteLine( (count * PBTYPE) + "\t" + pit );
                    count++;
                }
                for( int i = 12; i < args.Length; i++ ){
                    sw.WriteLine( (count * PBTYPE) + "\t" + args[i] );
                    count++;
                }
            }
        }
        using( StreamWriter sw = new StreamWriter( Path.Combine( path, exe_name + ".log" ), true ) ){
            sw.WriteLine( arg );
            Process p = null;
            try{
                p = new Process();
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.FileName = Path.Combine( path, "_" + exe_name + ".exe" );
                psi.Arguments = arg;
                psi.CreateNoWindow = true;
                psi.UseShellExecute = false;
                psi.UseShellExecute = false;
                p.StartInfo = psi;
                p.Start();
                p.WaitForExit();
            }catch( Exception ex ){
                sw.WriteLine( "Resampler.Main(string[]); ex=" + ex );
            }finally{
                if( p != null ){
                    try{
                        p.Dispose();
                    }catch{
                    }
                }
            }
        }
    }
}