Ejemplo n.º 1
0
 /// <summary>
 /// Split the current asset at the current position. The first part keeps the same name and the second part is renamed.
 /// Ask for confirmation before splitting.
 /// For the moment split is only permitted while the asset is playing.
 /// TODO: play from the splitting point to test if the position is fine; fine tune the position.
 /// </summary>
 private void splitAssetToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (mAssetBox.SelectedIndex >= 0 && mPlayer.State == AudioPlayerState.paused)
     {
         int             selected = mAssetBox.SelectedIndex;
         AudioMediaAsset asset    = mPlayList[selected];
         SplitForm       dialog   = new SplitForm(asset, mPlayer);
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             ArrayList assets = asset.Split(mPlayer.CurrentTimePosition);
             mPlayer.Stop();
             mManager.DeleteAsset(asset);
             mPlayList.RemoveAt(selected);
             mAssetBox.Items.RemoveAt(selected);
             AudioMediaAsset before = (AudioMediaAsset)assets[0];
             mManager.AddAsset(before);
             mPlayList.Insert(selected, before);
             mManager.RenameAsset(before, asset.Name);
             mAssetBox.Items.Insert(selected, before.Name);
             AudioMediaAsset after = (AudioMediaAsset)assets[1];
             mManager.AddAsset(after);
             mPlayList.Insert(selected + 1, after);
             mManager.RenameAsset(after, GetAfterName(asset.Name));
             mAssetBox.Items.Insert(selected + 1, after.Name);
             mAssetBox.SelectedIndex = selected + 1;
             UpdateButtons();
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Add new assets to the list. A same path cannot be added twice.
        /// </summary>
        private void importAudioAssetsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter      = "Wave files (*.wav)|*.wav|Any file|*.*";
            dialog.Multiselect = true;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                foreach (string path in dialog.FileNames)
                {
                    AudioMediaAsset asset = new AudioMediaAsset(path);
                    if (asset.Validate())
                    {
                        asset = (AudioMediaAsset)mManager.CopyAsset(asset);
                        mManager.RenameAsset(asset, Path.GetFileNameWithoutExtension(path));
                        mAssetBox.Items.Add(asset.Name);
                        mPlayList.Add(asset);
                        if (mPlayer.State == AudioPlayerState.stopped)
                        {
                            mAssetBox.SelectedIndex = mAssetBox.Items.Count - 1;
                        }
                        renameAssetToolStripMenuItem.Enabled = true;
                        deleteAssetToolStripMenuItem.Enabled = true;
                        // Create a node for this asset
                        mProject.AppendPhrase(asset);
                    }
                    else
                    {
                        MessageBox.Show("Unable to read audio file \"" + path + "\", format is not supported.",
                                        "Unsupported audio format", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                UpdateButtons();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new split form to let the user decide where to split the asset.
 /// </summary>
 /// <param name="asset">The asset to split.</param>
 /// <param name="player">The application's audio player for preview.</param>
 public SplitForm(AudioMediaAsset asset, AudioPlayer player)
 {
     InitializeComponent();
     mAsset  = asset;
     mTime   = player.CurrentTimePosition;
     mPlayer = player;
 }
Ejemplo n.º 4
0
Archivo: Form1.cs Proyecto: daisy/obi
        private void btnInsert_Click(object sender, System.EventArgs e)
        {
            AudioClip       ob_AudioClip = new AudioClip("c:\\atest\\a\\a.wav", 3000, 9000);
            AudioMediaAsset am           = new AudioMediaAsset(ob_AudioClip.Channels, ob_AudioClip.BitDepth, ob_AudioClip.SampleRate);

            am.AddClip(ob_AudioClip);

            AudioClip ob_AudioClip1 = new AudioClip("c:\\atest\\a\\a.wav", 3000, 6000);

            am.AddClip(ob_AudioClip1);

            AudioClip ob_AudioClip2 = new AudioClip("c:\\atest\\a\\a.wav", 6000, 9000);

            am.AddClip(ob_AudioClip2);

            //AudioClip  ob_AudioClip3   = new AudioClip ( "c:\\atest\\a\\Alpha.wav" , 9000 , 12000) ;
            //am.AddClip (ob_AudioClip3) ;

            double BeginTime  = 3000;
            double EndTime    = 8000;
            double InsertTime = 3000;

            MessageBox.Show(" ");
            CreateAsset();

            InsertAudioAssetCommand ComInsert = new InsertAudioAssetCommand(am0, am, InsertTime);

            ComInsert.Do();
//ComInsert.Undo () ;
            //am.InsertAsset (am0 , InsertTime);
            //am.InsertAsset (am.GetChunk(BeginTime , EndTime ) , InsertTime);
            Display(am);
            MessageBox.Show(am.LengthInMilliseconds.ToString());
        }
Ejemplo n.º 5
0
Archivo: Form1.cs Proyecto: daisy/obi
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            AudioMediaAsset a = am.GetAsset("amMediaAsset2") as AudioMediaAsset;

            MessageBox.Show(a.Name);
            am.DeleteAsset(a);
            AddList(am.Assets, am.m_htExists);
            MessageBox.Show("Deleted");
        }
Ejemplo n.º 6
0
Archivo: Form1.cs Proyecto: daisy/obi
        private void button1_Click(object sender, System.EventArgs e)
        {
            AudioMediaAsset a = am.GetAsset("amMediaAsset2") as AudioMediaAsset;

            MessageBox.Show(a.Name);
            am.RenameAsset(a, "Name");
            AddList(am.Assets, am.m_htExists);
            MessageBox.Show("Renamed");
        }
Ejemplo n.º 7
0
Archivo: Form1.cs Proyecto: daisy/obi
        private void btnCopy_Click(object sender, System.EventArgs e)
        {
            AudioMediaAsset a = am.GetAsset("amMediaAsset3") as AudioMediaAsset;

            a.Name = null;
            MessageBox.Show(a.Manager.ToString());
            am.CopyAsset(a);
            AddList(am.Assets, am.m_htExists);
            MessageBox.Show("Asset copied");
        }
Ejemplo n.º 8
0
Archivo: Form1.cs Proyecto: daisy/obi
        private void btnDeleteAsset_Click(object sender, System.EventArgs e)
        {
            AudioClip       Clip1    = new AudioClip("c:\\atest\\a\\Delete.wav", 0, 1000);
            AudioClip       Clip2    = new AudioClip("c:\\atest\\a\\Delete.wav", 1000, 2000);
            AudioMediaAsset amdelete = new AudioMediaAsset(Clip1.Channels, Clip1.BitDepth, Clip1.SampleRate);

            amdelete.AddClip(Clip1);
            amdelete.AddClip(Clip2);
//amdelete.Delete () ;
            MessageBox.Show("done");
        }
Ejemplo n.º 9
0
Archivo: Form1.cs Proyecto: daisy/obi
        private void btnMerge_Click(object sender, System.EventArgs e)
        {
            CreateAsset();
            AudioMediaAsset am1 = am0.Copy() as AudioMediaAsset;

            MergeAudioAssetsCommand ComMerge = new MergeAudioAssetsCommand(am0, am1);

            ComMerge.Do();
            //ComMerge.Undo () ;
            MessageBox.Show(am0.LengthInMilliseconds.ToString());
            Display(am0);
        }
Ejemplo n.º 10
0
Archivo: Form1.cs Proyecto: daisy/obi
        void Display(AudioMediaAsset Asset)
        {
            lbDisplay.Items.Clear();
            string    sTemp;
            AudioClip DisplayClip;

            for (int i = 0; i < Asset.m_alClipList.Count; i++)
            {
                DisplayClip = Asset.m_alClipList [i] as AudioClip;
                sTemp       = DisplayClip.Path + "-    " + DisplayClip.BeginTime + "-    " + DisplayClip.EndTime;
                lbDisplay.Items.Add(sTemp);
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Rename the currently selected asset.
 /// </summary>
 private void renameAssetToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (mPlayList.Count > 0)
     {
         int               selected = mAssetBox.SelectedIndex;
         AudioMediaAsset   asset    = mPlayList[selected];
         RenameAssetDialog dialog   = new RenameAssetDialog(asset.Name);
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             mManager.RenameAsset(asset, dialog.AssetName);
             mAssetBox.Items[selected] = asset.Name;
         }
     }
 }
Ejemplo n.º 12
0
Archivo: Form1.cs Proyecto: daisy/obi
        private void btnGetChunk_Click(object sender, System.EventArgs e)
        {
            CreateAsset();
            //Display  (am0) ;


            double          BeginTime = 4850;
            double          EndTime   = 7400;
            AudioMediaAsset am1       = am0.GetChunk(BeginTime, EndTime) as AudioMediaAsset;

            Display(am1);
            MessageBox.Show(am1.LengthInMilliseconds.ToString());

//			Display  (am0) ;
//MessageBox.Show (am0.LengthInMilliseconds.ToString () );
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Append a new audio asset to the root.
        /// Set the location and timing of the audio node to that of the asset.
        /// Set the text in the node to the label of the asset.
        /// The phrase is added to the list of phrases in that project.
        /// </summary>
        /// <param name="asset">The asset to append.</param>
        public void AppendPhrase(AudioMediaAsset asset)
        {
            CoreNode         node  = this.getPresentation().getCoreNodeFactory().createNode();
            ChannelsProperty prop  = (ChannelsProperty)node.getProperty(PropertyType.CHANNEL);
            AudioMedia       audio = (AudioMedia)this.getPresentation().getMediaFactory().createMedia(MediaType.AUDIO);

            audio.setLocation(new MediaLocation(asset.Path));
            audio.setClipEnd(new Time((long)Math.Round(asset.LengthInMilliseconds)));
            prop.setMedia(mAudioChannel, audio);
            TextMedia text = (TextMedia)this.getPresentation().getMediaFactory().createMedia(MediaType.TEXT);

            text.setText(asset.Name);
            prop.setMedia(mTextChannel, text);
            this.getPresentation().getRootNode().appendChild(node);
            mPhrases.Add(new Phrase(node, asset));
        }
Ejemplo n.º 14
0
Archivo: Form1.cs Proyecto: daisy/obi
        void CreateAsset()
        {
            ArrayList al           = new ArrayList();
            AudioClip ob_AudioClip = new AudioClip("c:\\atest\\a\\A1.wav", 0, 8000);

            al.Add(ob_AudioClip);
            AudioClip ob_AudioClip1 = new AudioClip("c:\\atest\\a\\b1.wav", 2000, 9000);

            al.Add(ob_AudioClip1);
            AudioClip ob_AudioClip2 = new AudioClip("c:\\atest\\a\\c1.wav", 3000, 10000);

            al.Add(ob_AudioClip2);

            AudioClip ob_AudioClip3 = new AudioClip("c:\\atest\\a\\d1.wav", 2000, 12000);

            al.Add(ob_AudioClip3);

            am0 = new AudioMediaAsset(al);
        }
Ejemplo n.º 15
0
Archivo: Form1.cs Proyecto: daisy/obi
        private void btnStart_Click(object sender, System.EventArgs e)
        {
            AudioClip ob_Clip  = new AudioClip("c:\\atest\\a\\Num.wav", 100, 3000);
            AudioClip ob_Clip1 = new AudioClip("c:\\atest\\a\\Alpha.wav", 100, 3000);
            ArrayList al       = new ArrayList();

            al.Add(ob_Clip);
            al.Add(ob_Clip1);
            am.NewAudioMediaAsset(2, 8, 22050);
            am.NewAudioMediaAsset(al);
            am.NewAudioMediaAsset(2, 8, 22050);
            MessageBox.Show(" ");
            AudioMediaAsset Asset = new AudioMediaAsset(1, 16, 44100);

//Asset.Name = "Added" ;
            am.AddAsset(Asset);

            AddList(am.Assets, am.m_htExists);
            MessageBox.Show("Done");
        }
Ejemplo n.º 16
0
Archivo: Form1.cs Proyecto: daisy/obi
        private void btnDetectPhrases_Click(object sender, System.EventArgs e)
        {
            AudioClip       ob_AudioClip = new AudioClip("c:\\s\\sil22-8-2.wav", 0, 2000);
            AudioMediaAsset am           = new AudioMediaAsset(ob_AudioClip.Channels, ob_AudioClip.BitDepth, ob_AudioClip.SampleRate);

            am.AddClip(ob_AudioClip);
            long Sil = am.GetSilenceAmplitude(am);

            Sil = Sil + 3;
            MessageBox.Show(Sil.ToString());

            ArrayList al = new ArrayList();
//AudioClip ob_AudioClip1 = new AudioClip ("c:\\s\\Detect22-8-2-new.wav" ) ;
//al.Add (ob_AudioClip1 ) ;

            //al.Add(ob_AudioClip) ;
            AudioClip ob_AudioClip2 = new AudioClip("c:\\s\\Detect22-8-2.wav");

            al.Add(ob_AudioClip2);
            AudioMediaAsset amd = new AudioMediaAsset(al);

            a.AddAsset(amd);
            double dLength = 500;
            double dBefore = 100;
//ArrayList alAsset =  amd.ApplyPhraseDetection (Sil , dLength , dBefore) ;
            PhraseDetectionCommand ob_PhraseDetectionCommand = new PhraseDetectionCommand(amd, Sil, dLength, dBefore);

            ob_PhraseDetectionCommand.Do();
            ArrayList alAsset = ob_PhraseDetectionCommand.AssetList;

            am0 = alAsset   [1] as AudioMediaAsset;
//MessageBox.Show (alAsset.Count.ToString ()) ;
            MessageBox.Show("Done");
            AudioMediaAsset DisplayAsset;

            for (int i = 0; i < alAsset.Count; i++)
            {
                DisplayAsset = alAsset  [i] as AudioMediaAsset;
                MessageBox.Show(DisplayAsset.LengthInMilliseconds.ToString());
            }
        }
Ejemplo n.º 17
0
 private void btnRecord_Click(object sender, System.EventArgs e)
 {
     ob_VuMeter.ScaleFactor      = 2;
     ob_VuMeter.SampleTimeLength = 2000;
     ob_VuMeter.UpperThreshold   = 120;
     ob_VuMeter.LowerThreshold   = 100;
     // Displays the VuMeter form
     ob_VuMeter.ShowForm();
     // assigns the VuMeter object to AudioPlayer property as it is routed through AudioPlayer for integrating it with AudioPlayer
     ar.VuMeterObject = ob_VuMeter;
     try
     {
         AssetManager    aManager = new AssetManager("C:\\Project");
         AudioMediaAsset am       = new AudioMediaAsset(2, 16, 44100);
         aManager.AddAsset(am);
         ar.StartRecording(am);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Merge this asset with the following. Only when the player is stopped.
 /// </summary>
 private void mergeAssetWithNextToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (mPlayer.State == AudioPlayerState.stopped && mAssetBox.SelectedIndex >= 0 &&
         mAssetBox.SelectedIndex < mAssetBox.Items.Count - 1 &&
         MessageBox.Show("Are you sure that you want to merge this asset with the following one?\nThis operation cannot be undone.",
                         "Merge the assets?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
     {
         int             selected = mAssetBox.SelectedIndex;
         AudioMediaAsset merged   = (AudioMediaAsset)mPlayList[selected].MergeWith(mPlayList[selected + 1]);
         merged.Name = mPlayList[selected].Name;
         mManager.DeleteAsset(mPlayList[selected]);
         mManager.DeleteAsset(mPlayList[selected + 1]);
         mManager.AddAsset(merged);
         mPlayList.RemoveRange(selected, 2);
         mPlayList.Insert(selected, merged);
         mAssetBox.Items.RemoveAt(selected + 1);
         mAssetBox.Items.RemoveAt(selected);
         mAssetBox.Items.Insert(selected, merged.Name);
         mAssetBox.SelectedIndex = selected;
         UpdateButtons();
     }
 }
Ejemplo n.º 19
0
        private void btnOpen_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "wave files(*.wav|*.wav";
            ofd.ShowDialog();
            AudioClip ob_AudioClip;

            if (textBox1.Text == "" && textBox2.Text == "")
            {
                ob_AudioClip = new AudioClip(ofd.FileName);
            }
            else
            {
                ob_AudioClip = new AudioClip(ofd.FileName, Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text));
            }


            if (am == null)
            {
                am = new AudioMediaAsset(ob_AudioClip.Channels, ob_AudioClip.BitDepth, ob_AudioClip.SampleRate);
            }

            am.AddClip(ob_AudioClip);
            textBox1.Clear();
            textBox2.Clear();



            ofd.Dispose();

/*
 *                      ofd.ShowDialog();
 *                      textBox2.Text = ofd.FileName;
 */
        }
Ejemplo n.º 20
0
Archivo: Form1.cs Proyecto: daisy/obi
        private void btnGetAsset_Click(object sender, System.EventArgs e)
        {
            AudioMediaAsset a = am.GetAsset("amMediaAsset3") as AudioMediaAsset;

            MessageBox.Show(a.Name);
        }
Ejemplo n.º 21
0
Archivo: Phrase.cs Proyecto: daisy/obi
        private AudioMediaAsset mAsset;  // the audio asset for this phrase

        public Phrase(CoreNode node, AudioMediaAsset asset)
        {
            mNode  = node;
            mAsset = asset;
        }