Base class for cutscene scripts.
Inheritance: GuiBase
 private void AddEnd()
 {
     if (selectedRow != -1 && selectedRow < Cuts.GetCollection().Count())
     {
         Cuts.GetCollection().ElementAt <Cut>(selectedRow).End = new TimeSpan(0, VideoViewer.currentTime.Hours, VideoViewer.currentTime.Minutes, VideoViewer.currentTime.Seconds);
     }
 }
Ejemplo n.º 2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.K))
        {
            active = true;
            cuts   = Cuts.firstCut;
        }


        if (active)
        {
            GM.Player.Imortal = true;
            switch (cuts)
            {
            case Cuts.firstCut:
                FirstCut();
                break;

            case Cuts.secondCut:
                SecondCut();
                break;

            case Cuts.end:
                break;
            }
        }

        if (!active)
        {
            Reset();
        }
    }
Ejemplo n.º 3
0
 private void Update()
 {
     if (Cuts.GetAt(selectedRow).End == TimeSpan.Zero)
     {
         Cuts.GetAt(selectedRow).End = Cuts.GetAt(selectedRow).Begin;
     }
 }
Ejemplo n.º 4
0
        /*  private void ResetPreview()
         * {
         *    // chargement de la miniature : on doit parcourir les 2 databases et afficher les perso checked
         *    var temp_image = new BitmapImage(Cuts.GetAt(selectedRow).Thumbnail.Background);
         *
         *
         *
         *
         *    var image = new WriteableBitmap(temp_image);
         *
         *
         *
         *    //multiplicateur de position
         *    int[] mult = { 1, 1 };
         *
         *    for (int i = 0; i < DbCharOne.Count; i++)
         *    {
         *        if (DbCharOne[i].IsPlayed)
         *        {
         *            //afficher la miniature a gauche
         *
         *            var char_picture = new BitmapImage(DbCharOne[i].PictureUri);
         *
         *
         *            //mise a echelle
         *            var Smaller_char = new TransformedBitmap(char_picture, new ScaleTransform(0.3, 0.3));
         *
         *
         *            //recupère l'image bitmap en pixel
         *            int stride = (int)Smaller_char.PixelWidth * (Smaller_char.Format.BitsPerPixel / 8);
         *
         *
         *            byte[] pixels = new byte[(int)Smaller_char.PixelHeight * stride];
         *            System.Diagnostics.Debug.WriteLine(pixels.Length);
         *
         *
         *            Smaller_char.CopyPixels( pixels, stride, 0);
         *
         *            // défini la zone de collage
         *            var rect = new Int32Rect(100 * mult[0], 100 * mult[0], Smaller_char.PixelWidth, Smaller_char.PixelHeight);
         *            mult[0]++;
         *            image.WritePixels(rect, pixels, stride, 0);
         *
         *        }
         *    }
         *    for (int i = 0; i < DbCharTwo.Count; i++)
         *    {
         *        if (DbCharTwo[i].IsPlayed)
         *        {
         *            //afficher la miniature a droite
         *            //afficher la miniature a gauche
         *
         *            var char_picture = new BitmapImage(DbCharTwo[i].PictureUri);
         *            //mise a echelle
         *            var Smaller_char = new TransformedBitmap(char_picture, new ScaleTransform(-0.3, 0.3));
         *            //recupère l'image bitmap en pixel
         *            int stride = (int)Smaller_char.PixelWidth * (Smaller_char.Format.BitsPerPixel / 8);
         *            byte[] pixels = new byte[(int)Smaller_char.PixelHeight * stride];
         *            Smaller_char.CopyPixels(pixels, stride, 0);
         *            // défini la zone de collage
         *            var rect = new Int32Rect(image.PixelWidth - Smaller_char.PixelWidth - (100 * mult[1]), 100 * mult[1], Smaller_char.PixelWidth, Smaller_char.PixelHeight);
         *            mult[1]++;
         *            image.WritePixels(rect, pixels, stride, 0);
         *        }
         *    }
         *
         *
         *    //envoie de la photo pour update
         *    var imgs = new ImageSend(image, mult);
         *    Messenger.Default.Send(imgs);
         * } */

        public void ChangeBackGround(NotificationMessage nm)
        {
            if (nm.Notification == "newBackGround")
            {
                Cuts.GetAt(selectedRow).Thumbnail.Background = new Uri((string)nm.Sender);
            }
        }
 /*
  * Functions
  */
 private void ResetVideo(Video v)
 {
     Cuts.VideoPath = v.Uri;
     CurrentVideo   = v;
     Cuts.ResetCutsDatabase();
     IsVideoLoaded = true;
 }
Ejemplo n.º 6
0
        public override bool MatchFilter(string filter)
        {
            string ucfilter = filter.ToUpper();

            if (base.MatchFilter(filter) == true)
            {
                return(true);
            }
            else if (Code.ToUpper().Contains(ucfilter))
            {
                return(true);
            }
            else if (Cuts.ToUpper().Contains(ucfilter))
            {
                return(true);
            }
            else if (Sidebar.ToUpper().Contains(ucfilter))
            {
                return(true);
            }
            else if (Door.ToUpper().Contains(ucfilter))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
 void Start()
 {
     rawImage = textScreen.GetComponent <RawImage> ();
     cas      = GetComponent <CustomAudioSource>();
     textScreen.SetActive(false);
     cuts = Cuts.end;
 }
Ejemplo n.º 8
0
        private void goButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(input.Filename) || string.IsNullOrEmpty(output.Filename) || string.IsNullOrEmpty(cuts.Filename))
            {
                MessageBox.Show("Can't create job: input not configured.", "Can't create job", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!output.Filename.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(Path.GetExtension(input.Filename).ToLower(System.Globalization.CultureInfo.InvariantCulture)))
            {
                MessageBox.Show("Can't create job: input and output have different types.", "Can't create job", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Cuts c = null;

            try
            {
                c = FilmCutter.ReadCutsFromFile(cuts.Filename);
            }
            catch (Exception)
            {
                MessageBox.Show("Error reading cutlist. Is it the correct format?", "Error reading cutlist", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string prefix = getAcceptableFilename(output.Filename, c.AllCuts.Count * 2);

            string[] tempfiles = generateNumberedFilenames(prefix, Path.GetExtension(output.Filename), c.AllCuts.Count * 2);

            AudioSplitJob split = new AudioSplitJob(input.Filename, prefix, c);

            for (int i = 1; i < tempfiles.Length; i += 2)
            {
                split.FilesToDelete.Add(tempfiles[i]);
            }

            int length = tempfiles.Length / 2;

            if (tempfiles.Length % 2 != 0)
            {
                length++;
            }
            string[] evens = new string[length];
            for (int i = 0; i < evens.Length; i++)
            {
                evens[i] = tempfiles[2 * i];
            }

            AudioJoinJob join = new AudioJoinJob(evens, output.Filename);

            join.FilesToDelete.AddRange(evens);
            // generate the join commandline later

            join.ClipLength = TimeSpan.FromSeconds((double)c.TotalFrames / c.Framerate);

            info.Jobs.addJobsWithDependencies(new SequentialChain(split, join));
            this.Dispose();
        }
 private void AddBegin()
 {
     if (selectedRow != -1 && selectedRow < Cuts.GetCollection().Count())
     {
         //needs to be improve (the static public currentTime)
         Cuts.GetCollection().ElementAt <Cut>(selectedRow).Begin = new TimeSpan(0, VideoViewer.currentTime.Hours, VideoViewer.currentTime.Minutes, VideoViewer.currentTime.Seconds);
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Метод добавляет планку
 /// </summary>
 /// <param name="length">длина планки, которую нужно добавить </param>
 /// <param name="name">название заказа</param>
 /// <param name="sleeve">характеристики гильзы</param>
 public void Cut(int length, string name, decimal initialCount, string sleeve)
 {
     InitialCount.Add(initialCount);
     Cuts.Add(length);
     Names.Add(name);
     Sleeves.Add(sleeve);
     FreeLength -= length;
     CurrentCountDesiredInPlank++;
 }
Ejemplo n.º 11
0
 void TransistToEnd()
 {
     timer = 0;
     playerAnim.SetBool("Climbing", false);
     playerMove.SetBool("Climbing2", false);
     player.GetComponent <SpriteRenderer> ().enabled = false;
     KickedFromWall.active = true;
     cuts = Cuts.end;
 }
Ejemplo n.º 12
0
 private void Add()
 {
     //System.Diagnostics.Debug.WriteLine("Instance: " + Cuts.GetCollection().ElementAt(0).Name);
     Cuts.AddCut(new Cut {
         Name = "Sans_nom", Begin = TimeSpan.Zero, End = TimeSpan.Zero, Thumbnail = new Miniature()
     });
     if (Cuts.VideoPath != null)
     {
         IsExportable = true;
     }
 }
Ejemplo n.º 13
0
        public List <int> GetCutsList()
        {
            List <int> output = new List <int>();

            char[] cutsArray = Cuts.ToCharArray();
            foreach (char currentChar in cutsArray)
            {
                output.Add(int.Parse(currentChar.ToString()));
            }
            return(output);
        }
Ejemplo n.º 14
0
        public void UpdateCutList()
        {
            Cuts.Clear();

            Cut c = FirstCut;

            while (c != null)
            {
                Cuts.Add(c);
                c = c.NextCut;
            }
        }
Ejemplo n.º 15
0
 void Reset()
 {
     timer = 0;
     KickedFromWall.active             = false;
     cutSceneCamera.transform.position = panPoints [0].transform.position;
     player.transform.position         = playerPanPoints [0].transform.position;
     cuts = Cuts.firstCut;
     cutSceneCamera.orthographicSize = 5;
     player.GetComponent <SpriteRenderer> ().enabled = true;
     playerMove.SetBool("Climbing2", false);
     playerAnim.SetBool("Climbing", true);
     cutSceneCamera.enabled = false;
 }
Ejemplo n.º 16
0
 void TransistToSecondCut()
 {
     if (cuts != Cuts.secondCut)
     {
         timer = 0;
         playerMove.SetBool("Climbing", false);
         playerMove.SetBool("Climbing2", true);
         cutSceneCamera.transform.position = panPoints [2].transform.position;
         cutSceneCamera.orthographicSize   = 9;
         cuts          = Cuts.secondCut;
         playedFanfare = false;
     }
 }
Ejemplo n.º 17
0
    // Use this for initialization
    public static IEnumerator Generate(System.Random rand)
    {
        ArchitectureFactory architectureFactory = new ArchitectureFactory();

        Architecture.direction dir;

        foreach (Room room in Map.roomObjs)
        {
            if (room.roomType == roomType.common)
            {
                yield return(new WaitForSecondsRealtime(0.25f));

                for (int i = 0; i < 3; i++)
                {
                    ArchitectureType type = (ArchitectureType)rand.Next(0, 4);

                    Architecture arch = architectureFactory.CreateArchitecture(type);
                    arch.randomGen = rand;

                    dir = arch.GetRandom();

                    arch.Create(room, dir);
                }

                //int createPool = Random.Range(0, 6);//20%

                //if (createPool == 0)
                //{
                //    Pools pool = ScriptableObject.CreateInstance("Pools") as Pools;

                //    dir = pool.GetRandom();

                //    pool.Create(room, dir);
                //}

                int createCuts = rand.Next(0, 2);//50%
                if (createCuts == 0)
                {
                    Cuts cuts = new Cuts();
                    cuts.randomGen = rand;

                    dir = cuts.GetRandom();

                    cuts.Create(room, dir);
                }
            }
        }
        yield return(0);
    }
Ejemplo n.º 18
0
        private void updateZoneButton_Click(object sender, EventArgs e)
        {
            Cuts old = cuts.clone();

            removeSelectedZones();

            if (addSelectedSection())
            {
                updateListView();
            }
            else
            {
                cuts = old;
            }
        }
Ejemplo n.º 19
0
 private void Del()
 {
     if ((selectedRow != -1) && (selectedRow < Cuts.Count()))
     {
         Cuts.RemoveAt(selectedRow);
         MessengBool reset = new MessengBool();
         reset.DisableButton = true;
         Messenger.Default.Send(reset);
         ResetSelectedRow();
         if (Cuts.Count() == 0)
         {
             IsExportable = false;
         }
     }
 }
Ejemplo n.º 20
0
        private void OpenB()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Fichiers image (*.jpg, *.png)| *.jpg; *.png";
            if (openFileDialog.ShowDialog() == true)
            {
                if (ValidFile(openFileDialog.FileName, 1920, 1080))
                {
                    Cuts.GetAt(selectedRow).Thumbnail.Background = new Uri(openFileDialog.FileName);
                    Background = new BitmapImage(new Uri(openFileDialog.FileName));
                }
                else
                {
                    MessageBox.Show("L'image doit être en 16:9");
                }
            }
        }
Ejemplo n.º 21
0
        public override string ToString()
        {
            var builder = new System.Text.StringBuilder();

            builder.AppendFormat("{0} {{", nameof(LapCompletedInfo)).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(CarId), CarId.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(LapTime), LapTime.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(Cuts), Cuts.ToString()).AppendLine();
            builder.AppendFormat("    {0} = {1}", nameof(GripLevel), GripLevel.ToString()).AppendLine();
            builder.AppendFormat("    Leaderboard: ");
            for (var i = 0; i < Leaderboard.Count; i++)
            {
                LeaderboardEntry entry = Leaderboard[i];
                builder.AppendFormat("    - {0}: {1}", i, entry).AppendLine();
            }

            builder.AppendFormat("}}").AppendLine();
            return(builder.ToString());
        }
Ejemplo n.º 22
0
        private void SetSelectedRow(ListIndex li)
        {
            selectedRow      = li.getValue();
            RefreshButton    = true;
            BackgroundButton = true;
            //chargement des databases
            if (selectedRow != -1)
            {
                var thumb = Cuts.GetAt(selectedRow).Thumbnail;
                TeamOne   = Cuts.GetAt(selectedRow).Thumbnail.TeamOne;
                TeamTwo   = Cuts.GetAt(selectedRow).Thumbnail.TeamTwo;
                DbCharOne = Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase;
                DbCharTwo = Cuts.GetAt(selectedRow).Thumbnail.TeamTwo.DataBase;
                Debug.WriteLine(Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase[0].Name);
                Debug.WriteLine(Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase[0].IsPlayed);

                Background = new BitmapImage(thumb.Background);
                ResetPreview();
            }
        }
Ejemplo n.º 23
0
        private void updateZoneButton_Click(object sender, EventArgs e)
        {
            if (sections.SelectedItems.Count != 1)
            {
                MessageBox.Show("You must select exactly one section to update", "Bad selection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Cuts old = cuts.clone();

            removeSelectedZones();

            if (addSelectedSection())
            {
                updateListView();
            }
            else
            {
                cuts = old;
            }
        }
Ejemplo n.º 24
0
    void Update()
    {
        if (cuts != Cuts.end)
        {
            if (!hasPlayed)
            {
                cas.PlayOnce();
                hasPlayed = true;
            }
        }
        if (Input.GetKeyDown(KeyCode.T))
        {
            active = true;
            cuts   = Cuts.cutOne;
        }

        if (active)
        {
            switch (cuts)
            {
            case Cuts.cutOne:
                CutOne();
                break;

            case Cuts.cutTwo:
                CutTwo();
                break;

            case Cuts.end:
                End();
                break;
            }
        }

        if (!active)
        {
            reset();
        }
    }
Ejemplo n.º 25
0
        private void updateZoneButton_Click(object sender, EventArgs e)
        {
            Cuts old = cuts.clone();
            removeSelectedZones();

            if (addSelectedSection())
                updateListView();
            else
                cuts = old;
        }
Ejemplo n.º 26
0
 void reset()
 {
     timer     = 0;
     cuts      = Cuts.end;
     hasPlayed = false;
 }
Ejemplo n.º 27
0
        private void ResetPreview()
        {
            // chargement de la miniature : on doit parcourir les 2 databases et afficher les perso checked
            Bitmap temp_image = new Bitmap(Cuts.GetAt(selectedRow).Thumbnail.Background.OriginalString);

            int      width    = temp_image.Width;
            int      height   = temp_image.Height;
            float    sizeChar = width / 38.4F;
            Graphics g        = Graphics.FromImage(temp_image);

            g.InterpolationMode  = InterpolationMode.High;
            g.SmoothingMode      = SmoothingMode.HighQuality;
            g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.CompositingQuality = CompositingQuality.HighQuality;

            //create the outline of the text



            System.Drawing.FontFamily f = new System.Drawing.FontFamily("Arial");
            SolidBrush drawBrush        = new SolidBrush(System.Drawing.Color.White);

            System.Drawing.Pen pen       = new System.Drawing.Pen(System.Drawing.Color.Black, 5);
            PointF             drawPoint = new PointF(width / 4 - (TeamOne.TeamName.Length * sizeChar) / 2, height * 3 / 4);
            GraphicsPath       p         = new GraphicsPath();

            //write team name 1

            p.AddString(
                TeamOne.TeamName,       // text to draw
                f,                      // or any other font family
                (int)System.Drawing.FontStyle.Regular,
                g.DpiY * sizeChar / 72, // em size
                drawPoint,              // location where to draw text
                new StringFormat());    // set options here (e.g. center alignment)
            g.DrawPath(pen, p);
            g.FillPath(drawBrush, p);


            //write team name 2
            drawPoint.X = temp_image.Width - width / 4 - (TeamTwo.TeamName.Length * sizeChar) / 2;
            GraphicsPath p2 = new GraphicsPath();

            //write team name 1
            p2.AddString(
                TeamTwo.TeamName,       // text to draw
                f,                      // or any other font family
                (int)System.Drawing.FontStyle.Regular,
                g.DpiY * sizeChar / 72, // em size
                drawPoint,              // location where to draw text
                new StringFormat());    // set options here (e.g. center alignment)
            g.DrawPath(pen, p2);
            g.FillPath(drawBrush, p2);

            //multiplicateur de position
            List <int> posTab = new List <int>();

            // on vérifie une fois le tableau pour savoir combien de cases sont cochées
            for (int i = 0; i < DbCharOne.Count; i++)
            {
                if (DbCharOne[i].IsPlayed)
                {
                    posTab.Add(i);

                    Debug.Write(Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase[i].Name + ": ");
                    Debug.WriteLine(Cuts.GetAt(selectedRow).Thumbnail.TeamOne.DataBase[i].IsPlayed);
                }
            }
            // on parcours la liste des cases cochées
            for (int i = 0; i < posTab.Count; i++)
            {
                Character temp_char = DbCharOne[posTab[i]];
                int       nb_char   = posTab.Count;
                //afficher la miniature a gauche
                Bitmap char_picture = new Bitmap(temp_char.PictureUri.OriginalString);


                //mise a echelle
                int    newWidth     = (int)((char_picture.Width / (nb_char + 1)) * ((float)width / 1920));
                int    newHeight    = (int)((char_picture.Height / (nb_char + 1)) * ((float)width / 1920));
                Bitmap Smaller_char = new Bitmap(char_picture, new System.Drawing.Size(newWidth, newHeight));
                //Smaller_char.MakeTransparent();


                Rectangle rect = new Rectangle(width * (i + 1) / (2 + 2 * nb_char) - Smaller_char.Width / 2, height / 2 - (Smaller_char.Height) * 2 / 3, Smaller_char.Width, Smaller_char.Height);
                //image.WritePixels(rect, Data.Scan0, Data.Stride,100000);
                g.DrawImage(Smaller_char, rect);
            }

            posTab.Clear();

            // on vérifie une fois le tableau pour savoir combien de cases sont cochées
            for (int i = 0; i < DbCharTwo.Count; i++)
            {
                if (DbCharTwo[i].IsPlayed)
                {
                    posTab.Add(i);
                }
            }
            // on parcours la liste des cases cochées
            for (int i = 0; i < posTab.Count; i++)
            {
                Character temp_char = DbCharOne[posTab[i]];
                int       nb_char   = posTab.Count;
                //afficher la miniature a gauche

                Bitmap char_picture = new Bitmap(temp_char.PictureUri.OriginalString);
                int    newWidth     = (int)((char_picture.Width / (nb_char + 1)) * ((float)width / 1920));
                int    newHeight    = (int)((char_picture.Height / (nb_char + 1)) * ((float)width / 1920));
                Bitmap Smaller_char = new Bitmap(char_picture, new System.Drawing.Size(newWidth, newHeight));
                //Smaller_char.MakeTransparent();

                Smaller_char.RotateFlip(RotateFlipType.RotateNoneFlipX);


                Rectangle rect = new Rectangle(width - (width * (i + 1) / (2 + 2 * nb_char)) - Smaller_char.Width / 2, height / 2 - (Smaller_char.Height) * 2 / 3, Smaller_char.Width, Smaller_char.Height);
                //image.WritePixels(rect, Data.Scan0, Data.Stride,100000);
                g.DrawImage(Smaller_char, rect);
            }
            //change pas grand chose
            g.Dispose();


            IntPtr hBitmap = temp_image.GetHbitmap();

            try
            {
                var img_src = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                    hBitmap, IntPtr.Zero, Int32Rect.Empty,
                    System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
                WriteableBitmap wb   = new WriteableBitmap(img_src);
                var             imgs = new ImageSend(wb);
                Messenger.Default.Send(imgs);
            }
            finally
            {
                DeleteObject(hBitmap);
            }



            //change pas grand chose
            temp_image.Dispose();
        }
Ejemplo n.º 28
0
 public void CloseText()
 {
     timer = 0;
     cuts  = Cuts.cutTwo;
 }
Ejemplo n.º 29
0
 public void Activate(int index)
 {
     rawImage.texture = textMessages [index];
     active           = true;
     cuts             = Cuts.cutOne;
 }
Ejemplo n.º 30
0
 public AudioSplitJob(string input, string output, Cuts c)
 {
     this.c      = c;
     this.Input  = input;
     this.Output = output;
 }
Ejemplo n.º 31
0
        public void setup(Job job, StatusUpdate su)
        {
            this.audioJob = (AudioJob)job;

            this.su = su;


            //let's create avisynth script
            StringBuilder script = new StringBuilder();

            string id  = _uniqueId;
            string tmp = Path.Combine(Path.GetTempPath(), id);



            bool directShow = audioJob.Settings.ForceDecodingViaDirectShow;

            if (!directShow)
            {
                switch (Path.GetExtension(audioJob.Input).ToLower())
                {
                case ".ac3":
                    script.AppendFormat("NicAc3Source(\"{0}\"", audioJob.Input);
                    if (audioJob.Settings.AutoGain)
                    {
                        script.AppendFormat(", DRC=1){0}", Environment.NewLine);
                    }
                    else
                    {
                        script.Append(")");
                    }
                    break;

                case ".avs":
                    script.AppendFormat("Import(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
                    break;

                case ".wav":
                    script.AppendFormat("WavSource(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
                    break;

                case ".dts":
                    script.AppendFormat("NicDtsSource(\"{0}\")", audioJob.Input);
                    if (audioJob.Settings.AutoGain)
                    {
                        script.AppendFormat(", DRC=1){0}", Environment.NewLine);
                    }
                    else
                    {
                        script.Append(")");
                    }
                    break;

                case ".mpa":
                case ".mpg":
                case ".mp2":
                    script.AppendFormat("NicMPASource(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
                    break;

                case ".mp3":
                    script.AppendFormat("NicMPG123Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
                    break;

                default:
                    directShow = true;
                    break;
                }
            }
            if (directShow)
            {
                script.AppendFormat("DirectShowSource(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
            }

            script.AppendFormat("EnsureVBRMP3Sync(){0}", Environment.NewLine);


            if (audioJob.Delay != 0)
            {
                script.AppendFormat("DelayAudio({0}.0/1000.0){1}", audioJob.Delay, Environment.NewLine);
            }

            if (audioJob.Settings.ImproveAccuracy || audioJob.Settings.AutoGain /* to fix the bug */)
            {
                script.AppendFormat("ConvertAudioToFloat(){0}", Environment.NewLine);
            }

            if (!string.IsNullOrEmpty(audioJob.CutFile))
            {
                try
                {
                    Cuts cuts = FilmCutter.ReadCutsFromFile(audioJob.CutFile);
                    script.AppendLine(FilmCutter.GetCutsScript(cuts, true));
                }
                catch (FileNotFoundException)
                {
                    deleteTempFiles();
                    throw new MissingFileException(audioJob.CutFile);
                }
                catch (Exception)
                {
                    deleteTempFiles();
                    throw new JobRunException("Broken cuts file, " + audioJob.CutFile + ", can't continue.");
                }
            }

            if (audioJob.Settings.AutoGain)
            {
                script.AppendFormat("Normalize(){0}", Environment.NewLine);
            }

            switch (audioJob.Settings.DownmixMode)
            {
            case ChannelMode.KeepOriginal:
                break;

            case ChannelMode.ConvertToMono:
                script.AppendFormat("ConvertToMono(){0}", Environment.NewLine);
                break;

            case ChannelMode.DPLDownmix:
                script.Append("6<=Audiochannels(last)?x_dpl" + id + @"(ConvertAudioToFloat(last)):last" + Environment.NewLine);
                break;

            case ChannelMode.DPLIIDownmix:
                script.Append("6<=Audiochannels(last)?x_dpl2" + id + @"(ConvertAudioToFloat(last)):last" + Environment.NewLine);
                break;

            case ChannelMode.StereoDownmix:
                script.Append("6<=Audiochannels(last)?x_stereo" + id + @"(ConvertAudioToFloat(last)):last" + Environment.NewLine);
                break;

            case ChannelMode.Upmix:
                createTemporallyEqFiles(tmp);
                script.Append("2==Audiochannels(last)?x_upmix" + id + @"(last):last" + Environment.NewLine);
                break;

            case ChannelMode.UpmixUsingSoxEq:
                script.Append("2==Audiochannels(last)?x_upmixR" + id + @"(last):last" + Environment.NewLine);
                break;

            case ChannelMode.UpmixWithCenterChannelDialog:
                script.Append("2==Audiochannels(last)?x_upmixC" + id + @"(last):last" + Environment.NewLine);
                break;
            }

            //let's obtain command line & other staff
            if (audioJob.Settings is AC3Settings)
            {
                script.Append("6<=Audiochannels(last)?GetChannel(last,1,3,2,5,6,4):last" + Environment.NewLine);
                _mustSendWavHeaderToEncoderStdIn = true;
                AC3Settings n = audioJob.Settings as AC3Settings;
                _encoderExecutablePath = this._settings.FFMpegPath;
                _encoderCommandLine    = "-i - -y -acodec ac3 -ab " + n.Bitrate + "k \"{0}\"";
            }
            if (audioJob.Settings is MP2Settings)
            {
                _mustSendWavHeaderToEncoderStdIn = true;
                MP2Settings n = audioJob.Settings as MP2Settings;
                _encoderExecutablePath = this._settings.FFMpegPath;
                _encoderCommandLine    = "-i - -y -acodec mp2 -ab " + n.Bitrate + "k \"{0}\"";
            }
            if (audioJob.Settings is WinAmpAACSettings)
            {
                _mustSendWavHeaderToEncoderStdIn = false;
                WinAmpAACSettings n = audioJob.Settings as WinAmpAACSettings;
                _encoderExecutablePath = this._settings.EncAacPlusPath;
                StringBuilder sb = new StringBuilder("- \"{0}\" --rawpcm {1} {3} {2} --cbr ");
                sb.Append(n.Bitrate * 1000);
                if (n.Mpeg2AAC)
                {
                    sb.Append(" --mpeg2aac");
                }
                switch (n.Profile)
                {
                case AacProfile.PS:
                    break;

                case AacProfile.HE:
                    sb.Append(" --nops");
                    break;

                case AacProfile.LC:
                    sb.Append(" --lc");
                    break;
                }
                switch (n.StereoMode)
                {
                case WinAmpAACSettings.AacStereoMode.Dual:
                    sb.Append(" --dc");
                    break;

                case WinAmpAACSettings.AacStereoMode.Joint:
                    break;

                case WinAmpAACSettings.AacStereoMode.Independent:
                    sb.Append(" --is");
                    break;
                }
                _encoderCommandLine = sb.ToString();
            }

            if (audioJob.Settings is AudXSettings)
            {
                script.Append("ResampleAudio(last,48000)" + Environment.NewLine);
                script.Append("6==Audiochannels(last)?last:GetChannel(last,1,1,1,1,1,1)" + Environment.NewLine);
                _mustSendWavHeaderToEncoderStdIn = false;
                AudXSettings n = audioJob.Settings as AudXSettings;
                _encoderExecutablePath = this._settings.EncAudXPath;
                _encoderCommandLine    = "- \"{0}\" --q " + ((int)n.Quality) + " --raw {1}";
            }
            if (audioJob.Settings is OggVorbisSettings)
            {
                // http://forum.doom9.org/showthread.php?p=831098#post831098
                //if(!this._settings.FreshOggEnc2)
                script.Append("6==Audiochannels(last)?GetChannel(last,1,3,2,5,6,4):last" + Environment.NewLine);
                _mustSendWavHeaderToEncoderStdIn = false;
                OggVorbisSettings n = audioJob.Settings as OggVorbisSettings;
                _encoderExecutablePath = this._settings.OggEnc2Path;
                _encoderCommandLine    = "-Q --raw --raw-bits={2} --raw-chan={3} --raw-rate={1} --quality " + n.Quality.ToString(System.Globalization.CultureInfo.InvariantCulture) + " -o \"{0}\" -";
            }
            if (audioJob.Settings is NeroAACSettings)
            {
                _mustSendWavHeaderToEncoderStdIn = true;
                NeroAACSettings n   = audioJob.Settings as NeroAACSettings;
                NeroAACSettings nas = n;
                _encoderExecutablePath = this._settings.NeroAacEncPath;
                StringBuilder sb = new StringBuilder("-ignorelength ");
                switch (n.Profile)
                {
                case AacProfile.HE:
                    sb.Append("-he ");
                    break;

                case AacProfile.PS:
                    sb.Append("-hev2 ");
                    break;

                case AacProfile.LC:
                    sb.Append("-lc ");
                    break;
                }
                if (n.CreateHintTrack)
                {
                    sb.Append("-hinttrack ");
                }

                switch (n.BitrateMode)
                {
                case BitrateManagementMode.ABR:
                    sb.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "-br {0} ", n.Bitrate * 1000);
                    break;

                case BitrateManagementMode.CBR:
                    sb.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "-cbr {0} ", n.Bitrate * 1000);
                    break;

                case BitrateManagementMode.VBR:
                    sb.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "-q {0} ", n.Quality);
                    break;
                }

                sb.Append("-if - -of \"{0}\"");

                _encoderCommandLine = sb.ToString();
            }
            if (audioJob.Settings is FaacSettings)
            {
                FaacSettings f = audioJob.Settings as FaacSettings;
                _encoderExecutablePath           = this._settings.FaacPath;
                _mustSendWavHeaderToEncoderStdIn = false;
                switch (f.BitrateMode)
                {
                // {0} means output file name
                // {1} means samplerate in Hz
                // {2} means bits per sample
                // {3} means channel count
                // {4} means samplecount
                // {5} means size in bytes

                case BitrateManagementMode.VBR:
                    _encoderCommandLine = "-q " + f.Quality + " -o \"{0}\" -P -X -R {1} -B {2} -C {3} --mpeg-vers 4 -";
                    break;

                default:
                    _encoderCommandLine = "-b " + f.Bitrate + " -o \"{0}\" -P -X -R {1} -B {2} -C {3} --mpeg-vers 4 -";
                    break;
                }
            }
            if (audioJob.Settings is MP3Settings)
            {
                MP3Settings m = audioJob.Settings as MP3Settings;
                _mustSendWavHeaderToEncoderStdIn = true;
                _encoderExecutablePath           = this._settings.LamePath;

                switch (m.BitrateMode)
                {
                case BitrateManagementMode.VBR:
                    _encoderCommandLine = "-V " + (m.Quality / 10 - 1) + " -h --silent - \"{0}\"";
                    break;

                case BitrateManagementMode.CBR:
                    _encoderCommandLine = "-b " + m.Bitrate + " --cbr -h --silent - \"{0}\"";
                    break;

                case BitrateManagementMode.ABR:
                    _encoderCommandLine = "--abr " + m.Bitrate + " -h --silent - \"{0}\"";
                    break;
                }
            }

            //Just check encoder existance
            _encoderExecutablePath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, _encoderExecutablePath);
            if (!File.Exists(_encoderExecutablePath))
            {
                deleteTempFiles();
                throw new EncoderMissingException(_encoderExecutablePath);
            }

            script.AppendFormat("ConvertAudioTo16bit(){0}", Environment.NewLine);


            script.AppendLine(
                @"

return last

function x_dpl" + id + @"(clip a) 
{
	fl = GetChannel(a, 1)
	fr = GetChannel(a, 2)
	c = GetChannel(a, 3)
	sl = GetChannel(a, 5)
	sr = GetChannel(a, 6)
	ssr = MixAudio(sl, sr, 0.2222, 0.2222)
	ssl = Amplify(ssr, -1.0)
	fl_c = MixAudio(fl, c, 0.3254, 0.2301)
	fr_c = MixAudio(fr, c, 0.3254, 0.2301)
	l = MixAudio(ssl, fl_c, 1.0, 1.0)
	r = MixAudio(ssr, fr_c, 1.0, 1.0)
	return MergeChannels(l, r)
}

function x_dpl2" + id + @"(clip a) 
{
	fl = GetChannel(a, 1)
	fr = GetChannel(a, 2)
	c = GetChannel(a, 3)
	sl = GetChannel(a, 5)
	sr = GetChannel(a, 6)
	ssl = MixAudio(sl, sr, 0.2818, 0.1627).Amplify(-1.0)
	fl_c = MixAudio(fl, c, 0.3254, 0.2301)
	ssr = MixAudio(sl, sr, 0.1627, 0.2818)
	fr_c = MixAudio(fr, c, 0.3254, 0.2301)
	l = MixAudio(ssl, fl_c, 1.0, 1.0)
	r = MixAudio(ssr, fr_c, 1.0, 1.0)
	return MergeChannels(l, r)
}

function x_stereo" + id + @"(clip a) 
{
	fl = GetChannel(a, 1)
	fr = GetChannel(a, 2)
	c = GetChannel(a, 3)
	lfe = GetChannel(a, 4)
	sl = GetChannel(a, 5)
	sr = GetChannel(a, 6)
	l_sl = MixAudio(fl, sl, 0.2929, 0.2929)
	c_lfe = MixAudio(lfe, c, 0.2071, 0.2071)
	r_sr = MixAudio(fr, sr, 0.2929, 0.2929)
	l = MixAudio(l_sl, c_lfe, 1.0, 1.0)
	r = MixAudio(r_sr, c_lfe, 1.0, 1.0)
	return MergeChannels(l, r)
}

function x_upmix" + id + @"(clip a) 
{
    m = ConvertToMono(a)
    f = SuperEQ(a,""" + tmp + @"front.feq"")
    s = SuperEQ(a,""" + tmp + @"back.feq"") 
    c = SuperEQ(m,""" + tmp + @"center.feq"") 
    lfe = SuperEQ(m,""" + tmp + @"lfe.feq"") 
    return MergeChannels( f.getleftchannel, f.getrightchannel , c, lfe, s.getleftchannel, s.getrightchannel)
}

function x_upmixR" + id + @"(clip Stereo) 
{
	Front = mixaudio(Stereo.soxfilter(""filter 0-600""),mixaudio(Stereo.soxfilter(""filter 600-1200""),Stereo.soxfilter(""filter 1200-7000""),0.45,0.25),0.50,1)
	Back = mixaudio(Stereo.soxfilter(""filter 0-600""),mixaudio(Stereo.soxfilter(""filter 600-1200""),Stereo.soxfilter(""filter 1200-7000""),0.35,0.15),0.40,1)
	fl = GetLeftChannel(Front)
	fr = GetRightChannel(Front)
	cc = ConvertToMono(stereo).SoxFilter(""filter 625-24000"")
	lfe = ConvertToMono(stereo).SoxFilter(""lowpass 100"",""vol -0.5"")
	sl = GetLeftChannel(Back)
	sr = GetRightChannel(Back)
	sl = DelayAudio(sl,0.02)
	sr = DelayAudio(sr,0.02)
    return MergeChannels(fl,fr,cc,lfe,sl,sr)
}

function x_upmixC" + id + @"(clip stereo) 
{
	left = stereo.GetLeftChannel()
	right = stereo.GetRightChannel()
	fl = mixaudio(left.soxfilter(""filter 0-24000""),right.soxfilter(""filter 0-24000""),0.6,-0.5)
	fr = mixaudio(right.soxfilter(""filter 0-24000""),left.soxfilter(""filter 0-24000""),0.6,-0.5)
	cc = ConvertToMono(stereo).SoxFilter(""filter 625-24000"")
	lfe = ConvertToMono(stereo).SoxFilter(""lowpass 100"",""vol -0.5"")
	sl = mixaudio(left.soxfilter(""filter 0-24000""),right.soxfilter(""filter 0-24000""),0.5,-0.4)
	sr = mixaudio(right.soxfilter(""filter 0-24000""),left.soxfilter(""filter 0-24000""),0.5,-0.4)
	sl = DelayAudio(sl,0.02)
	sr = DelayAudio(sr,0.02)
    return MergeChannels(fl,fr,cc,lfe,sl,sr)
}
                                                                                                                                                     

"
                );
            _avisynthAudioScript = script.ToString();
        }