Exemplo n.º 1
0
        /// <summary>
        /// Produces a list of arguments by scanning Flags and input/output file specs
        /// as appropriate for a given utility subclass.
        /// </summary>
        /// <returns>a collection of arguments suitable for presenting to the RunAsync method</returns>
        protected ICollection <string> GetUtilityArgs()
        {
            ICollection <string> args = new List <string>(Flags);
            string infile             = null;
            string outfile            = null;

            if ((InputFile != null) && InputFile.Exists)
            {
                infile = UsesSameDirectory(InputFile, SoundFileDirectory)
                    ? InputFile.Name
                    : BridgeToCpInvoke.wGetShortPathName(InputFile.FullName);
            }
            if (OutputFile != null)
            {//use -o?, insert before input, use name or shortpath: SADIR or working
                if (OutputFile.Exists)
                {
                    OutputFile.Delete();
                }
                outfile = BridgeToCpInvoke.wGetShortPathName(OutputFile.FullName);
            }
            if (!string.IsNullOrWhiteSpace(outfile))
            {
            }
            if (!string.IsNullOrWhiteSpace(infile))
            {
                args.Add(infile);
            }

            return(args);
        }
Exemplo n.º 2
0
        //Determines whether a complete path is superfluous.
        private bool UsesSameDirectory(FileInfo file, string dir)
        {
            bool same = false;

            if (!string.IsNullOrWhiteSpace(dir))
            {
                same = BridgeToCpInvoke.wGetShortPathName(file.DirectoryName).ToLower().Equals(BridgeToCpInvoke.wGetShortPathName(dir).ToLower());
            }
            return(same);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Prepares an instance of Csound for Cscore processing outside of running an orchestra (i.e. "standalone Cscore").
        /// It is an alternative to csoundPreCompile(), csoundCompile(), and csoundPerform*()
        /// and should not be used with these functions.
        /// You must call this function before using the interface in "cscore.h" when you do not wish
        /// to compile an orchestra.
        /// Pass it the already open FILE* pointers to the input and output score files.
        /// </summary>
        /// <param name="ifile"></param>
        /// <param name="ofile"></param>
        /// <returns>CsoundStatus.Success on success and CsoundStaus.InitializationError or other error code if it fails.</returns>
        /// <returns></returns>
        public CsoundStatus InitializeCscore(FileInfo inFile, FileInfo outFile)
        {
            IntPtr       pInFile  = BridgeToCpInvoke.cfopen(inFile.FullName, "r");
            IntPtr       pOutFile = BridgeToCpInvoke.cfopen(outFile.FullName, "w");
            CsoundStatus result   = Int2StatusEnum(NativeMethods.csoundInitializeCscore(Engine, pInFile, pOutFile));

            if ((int)result < 0)
            {
                throw new Csound6NetException(Csound6NetException.CscoreFailed, "Init", result);
            }
            return(result);
        }