Exemplo n.º 1
0
        public SoundPlayer(byte[] soundBytes, SoundFileType fileType)
        {
            string fileExtension = ".wav";
            switch (fileType)
            {
                case SoundFileType.WAV:
                    fileExtension = ".wav";
                    break;
                case SoundFileType.MP3:
                    fileExtension = ".mp3";
                    break;
                case SoundFileType.MIDI:
                    fileExtension = ".mid";
                    break;
                //case SoundFileType.WMA:
                //    fileExtension = ".wma";
                //    break;
                default:
                    throw new Exception("Audio format is not supported.");
                    break;
            }

            _filePath = Path.GetTempPath() + "tempSound" + fileExtension;
            using (FileStream fs = new FileStream(_filePath, FileMode.Create, FileAccess.ReadWrite))
            {
                fs.Write(soundBytes, 0, soundBytes.Length);
            }
        }
Exemplo n.º 2
0
 public UrlFileSearchResult(IAudioSource audioSource, SoundFileType fileType, string url, string filename) :
     base(audioSource, fileType == SoundFileType.Music ? AudioSearchResultType.MusicFile : AudioSearchResultType.SoundFile)
 {
     this.FileType  = fileType;
     this.SourceUrl = url;
     this.Filename  = filename;
 }
Exemplo n.º 3
0
        public SoundPlayer(byte[] soundBytes, SoundFileType fileType)
        {
            string fileExtension = ".wav";

            switch (fileType)
            {
            case SoundFileType.WAV:
                fileExtension = ".wav";
                break;

            case SoundFileType.MP3:
                fileExtension = ".mp3";
                break;

            case SoundFileType.MIDI:
                fileExtension = ".mid";
                break;

            //case SoundFileType.WMA:
            //    fileExtension = ".wma";
            //    break;
            default:
                throw new Exception("Audio format is not supported.");
                break;
            }

            _filePath = Path.GetTempPath() + "tempSound" + fileExtension;
            using (FileStream fs = new FileStream(_filePath, FileMode.Create, FileAccess.ReadWrite))
            {
                fs.Write(soundBytes, 0, soundBytes.Length);
            }
        }
Exemplo n.º 4
0
 internal BasicFileElement(int ID, String filePath, SoundFileType fileType)
     : base(ID)
 {
     FilePath      = filePath;
     Title         = FileName;
     SoundFileType = fileType;
     m_Effects     = new Effects();
 }
Exemplo n.º 5
0
 private static String GetAbsolutePath(String relativePath, SoundFileType soundFileType)
 {
     if (soundFileType == SoundFileType.Music)
     {
         return(System.IO.Path.Combine(Ares.Settings.Settings.Instance.MusicDirectory, relativePath));
     }
     else
     {
         return(System.IO.Path.Combine(Ares.Settings.Settings.Instance.SoundDirectory, relativePath));
     }
 }
Exemplo n.º 6
0
 public IFileElement CreateFileElement(String filePath, SoundFileType fileType)
 {
     return(new BasicFileElement(GetNextID(), filePath, fileType));
 }
Exemplo n.º 7
0
        public List <KeyValuePair <IMode, List <IModeElement> > > GetRootElements(IProject project, String relativePath, SoundFileType soundFileType)
        {
            List <KeyValuePair <IMode, List <IModeElement> > > resultList = new List <KeyValuePair <IMode, List <IModeElement> > >();

            if (project == null)
            {
                return(resultList);
            }
            m_CurrentModeElement = null;
            m_SearchedPath       = GetAbsolutePath(relativePath, soundFileType);
            foreach (IMode mode in project.GetModes())
            {
                m_CurrentList = new HashSet <IModeElement>();
                foreach (IModeElement element in mode.GetElements())
                {
                    m_CurrentModeElement = element;
                    element.Visit(this);
                }
                if (m_CurrentList.Count > 0)
                {
                    List <IModeElement> modeElements = new List <IModeElement>(m_CurrentList);
                    resultList.Add(new KeyValuePair <IMode, List <IModeElement> >(mode, modeElements));
                }
            }
            return(resultList);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Convert a SoundFileType into its equivalent string.
 /// </summary>
 /// <param name="type">a SoundFileType value</param>
 /// <returns>The corresponding string expected by csound 6</returns>
 public static string AsSoundFileTypeString(SoundFileType type)
 {
     return((type == SoundFileType.TypDefault) ? null : SoundFileTypeNames[(int)type]);
 }