Beispiel #1
0
        /// <summary>
        /// Import an audio file to the project by creating a new node with audio from the file.
        /// The node is created but not actually added but a command is returned.
        /// </summary>
        /// <param name="path">Full path to the audio file to import.</param>
        /// <param name="contextNode">The context node before which to import the audio file.
        /// If null, add at the end.</param>
        /// <returns>The command for adding the node.</returns>
        public Commands.AddTreeNode ImportAudioFileCommand(string path, TreeNode contextNode)
        {
            Stream      input = File.OpenRead(path);
            PCMDataInfo info  = PCMDataInfo.parseRiffWaveHeader(input);

            input.Close();
            getPresentation().getMediaDataManager().getDefaultPCMFormat().setBitDepth(info.getBitDepth());
            getPresentation().getMediaDataManager().getDefaultPCMFormat().setNumberOfChannels(info.getNumberOfChannels());
            getPresentation().getMediaDataManager().getDefaultPCMFormat().setSampleRate(info.getSampleRate());
            AudioMediaData data = (AudioMediaData)
                                  getPresentation().getMediaDataFactory().createMediaData(typeof(AudioMediaData));

            data.appendAudioDataFromRiffWave(path);
            ManagedAudioMedia media = (ManagedAudioMedia)getPresentation().getMediaFactory().createAudioMedia();

            media.setMediaData(data);
            Channel          audio = GetSingleChannelByName(AUDIO_CHANNEL_NAME);
            ChannelsProperty prop  = getPresentation().getPropertyFactory().createChannelsProperty();

            prop.setMedia(audio, media);
            TreeNode node = getPresentation().getTreeNodeFactory().createNode();

            node.setProperty(prop);
            TreeNode root = getPresentation().getRootNode();

            Commands.AddTreeNode command = new Commands.AddTreeNode(node, root,
                                                                    contextNode == null ? root.getChildCount() : contextNode.getParent().indexOf(contextNode));
            return(command);
        }
Beispiel #2
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));
        }