public AudioSource GeneratePlayJukeAudioSource(BGMFileInfos file) { AudioClip clip = SoundFile.LoadBGM(file); this._clsBGMObserver.source.set_clip(clip); return(this._clsBGMObserver.source); }
public override void Execute() { SoundFile soundFile; try { soundFile = new SoundFile(options.InputPath); } catch (Exception ex) when(ex is IOException or UnauthorizedAccessException or NotSupportedException) { throw new ImuseSequencerException($"Cannot open input file: {ex.Message}", ex); } var target = options.Target == SoundTarget.Unknown ? soundFile.Target : options.Target; if (target == SoundTarget.Unknown) { throw new ImuseSequencerException("Unable to determine target device. Please specify it as an argument."); } if (options.ToFile) { PlayToFile(soundFile, target); } else { PlayToDevice(soundFile, target); } }
public void opensoundfile() { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.DefaultExt = ".mp3"; dialog.Filter = "Sound Files(*.mp3;*.wav)|*.mp3;*.wav"; Nullable <bool> result = dialog.ShowDialog(); if (result == true) { SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(dialog.FileName); if (System.IO.Path.GetExtension(dialog.FileName) == ".wav") { File.Copy(dialog.FileName, AppData + "\\Sounds\\" + System.IO.Path.GetFileName(dialog.FileName), true); file.extension = "wav"; } else if (System.IO.Path.GetExtension(dialog.FileName) == ".mp3") { ConvertMp3 converter = new ConvertMp3(dialog.FileName, AppData + "\\Sounds\\" + file.soundname + ".wav"); converter.ShowDialog(); file.extension = "mp3"; } file.filepath = AppData + "\\Sounds\\" + System.IO.Path.GetFileName(dialog.FileName); sounds.Add(file); System.Windows.Controls.ComboBoxItem SoundMenuItem = new System.Windows.Controls.ComboBoxItem(); this.soundselection.Items.Add(SoundMenuItem); } }
/* * private void ExtractFiles(BinaryReader br) * { * foreach(soundBank bank in soundBankList) * { * string bankExtractionPath = _extractionPath + "\\" + bank.relativePath + bank.idString + ".bnk"; * Directory.CreateDirectory(Path.GetDirectoryName(bankExtractionPath)); * using (FileStream writeStream = File.Create(bankExtractionPath)) * { * br.BaseStream.Seek(bank.headerOffset, 0); * byte[] headerBytes = new byte[bank.headerSize]; * headerBytes = br.ReadBytes((int)bank.headerSize); * * br.BaseStream.Seek(bank.hircOffset, 0); * byte[] hircBytes = new byte[bank.hircSize]; * hircBytes = br.ReadBytes((int)bank.hircSize); * * writeStream.Write(headerBytes, 0, headerBytes.Length); * writeStream.Write(hircBytes, 0, hircBytes.Length); * * writeStream.Close(); * } * } * * foreach(soundFile file in soundFileList) * { * string fileExtractionPath = _extractionPath + "\\" + file.relativePath + file.idString + ".wem"; * Directory.CreateDirectory(Path.GetDirectoryName(fileExtractionPath)); * using (FileStream writeStream = File.Create(fileExtractionPath)) * { * br.BaseStream.Seek(file.fileOffset, 0); * byte[] fileBytes = new byte[file.fileSize]; * fileBytes = br.ReadBytes((int)file.fileSize); * * writeStream.Write(fileBytes, 0, fileBytes.Length); * writeStream.Close(); * } * } * }*/ private void AsyncExtractFiles() { BinaryReader asyncBinaryReader = new BinaryReader(File.Open(_packPath, FileMode.Open, FileAccess.Read, FileShare.Read)); BinaryReader br = asyncBinaryReader; while ((soundBankList.Count + soundFileList.Count) > 0) { if (soundBankList.Count > 0) { SoundBank bank = soundBankList.First(); string bankExtractionPath = _extractionPath + "\\" + bank.relativePath + bank.idString + ".bnk"; Directory.CreateDirectory(Path.GetDirectoryName(bankExtractionPath)); using (FileStream writeStream = File.Create(bankExtractionPath)) { br.BaseStream.Seek(bank.headerOffset, 0); byte[] headerBytes = new byte[bank.headerSize]; headerBytes = br.ReadBytes((int)bank.headerSize); br.BaseStream.Seek(bank.hircOffset, 0); byte[] hircBytes = new byte[bank.hircSize]; hircBytes = br.ReadBytes((int)bank.hircSize); writeStream.Write(headerBytes, 0, headerBytes.Length); writeStream.Write(hircBytes, 0, hircBytes.Length); writeStream.Close(); } // Do the Json conversion BankReader bankReader = new BankReader(bankExtractionPath, isBigEndian); Trace.WriteLine("Extracted SoundBank " + bankExtractionPath.Replace(".bnk", ".(bnk+json)")); soundBankList.Remove(bank); } if (soundFileList.Count > 0) { SoundFile file = soundFileList.First(); string fileExtractionPath = _extractionPath + "\\" + file.relativePath + "SoundFiles\\" + file.idString + ".wem"; Directory.CreateDirectory(Path.GetDirectoryName(fileExtractionPath)); using (FileStream writeStream = File.Create(fileExtractionPath)) { br.BaseStream.Seek(file.fileOffset, 0); byte[] fileBytes = new byte[file.fileSize]; fileBytes = br.ReadBytes((int)file.fileSize); writeStream.Write(fileBytes, 0, fileBytes.Length); writeStream.Close(); } if (convertAfterExtraction && !isBigEndian) // H4 uses other codecs { conversionList.Add(fileExtractionPath); } Trace.WriteLine("Extracted SoundFile " + fileExtractionPath); soundFileList.Remove(file); } } }
public AudioSource GeneratePlayJukeAudioSource(BGMFileInfos file) { AudioClip clip = SoundFile.LoadBGM(file); _clsBGMObserver.source.clip = clip; return(_clsBGMObserver.source); }
public async Task <IHttpActionResult> PutSoundFile(int id, SoundFile soundFile) { if (!this.ModelState.IsValid) { return(BadRequest(this.ModelState)); } if (id != soundFile.Id) { return(BadRequest()); } this.db.Entry(soundFile).State = EntityState.Modified; try { await this.db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SoundFileExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public static SoundFile GetSound(string name, bool cache = true) { if (Soundcache.ContainsKey(name)) { return(Soundcache[name]); } //try //{ var buffer = new SoundFile(name); if (cache) { Soundcache.Add(name, buffer); } return(buffer); /* * } * catch * { * log.WriteLine("failed to load sound file: \"" + name + "\"", log.messageType.Error); * return null; * }*/ }
private void PlayToFile(SoundFile soundFile, SoundTarget target) { logger.Info($"Writing playback of [green]{options.InputPath}[/] to [green]{options.OutputPath}[/]..."); try { var transmitter = new MidiFileWriterTransmitter(); using (var engine = new ImuseEngine(transmitter, target, options.ImuseOptions)) { // Clean up, even with Ctrl+C ConsoleHelpers.SetupCancelHandler(engine, transmitter); engine.RegisterSound(0, soundFile); engine.StartSound(0); transmitter.Start(); transmitter.Write(options.OutputPath); ConsoleHelpers.TearDownCancelHandler(); } } catch (ImuseException ex) { throw new ImuseSequencerException(ex.Message, ex); } }
/// <summary> /// Play a file on the layer. If any previous file is playing it will be stopped. /// </summary> /// <param name="file">The file to play.</param> public ContinuousAction Play(SoundFile file) { ContinuousAction thisAction = new ContinuousAction(); void PlayInternal() { // Stop whatever was playing before. StopPlayingAll(true); // Queue the file. AL.SourceQueueBuffer(_pointer, file.Pointer); _playList.Add(file); Helpers.CheckErrorAL($"queuing single in source {_pointer}"); // Play it. AL.SourcePlay(_pointer); Status = SoundStatus.Playing; Helpers.CheckErrorAL($"playing single in source {_pointer}"); Debugger.Log(MessageType.Info, MessageSource.SoundManager, $"Started playing [{file.Name}] on {ToString()}."); thisAction.Done(); } // Check if forcing a fade out. if (FadeOutOnChange) { SetupForceFadeOut(PlayInternal); } else { ALThread.ExecuteALThread(PlayInternal); } return(thisAction); }
public int PlayWebRadio(IWebRadioElement webRadioElement, int fadeInTime, Action <bool> afterPlayed) { SoundFile soundFile = new SoundFile(webRadioElement, m_PlayMusicOnAllSpeakers); FileStarted(webRadioElement); int handle = PlayingModule.FilePlayer.PlayFile(soundFile, fadeInTime, (id, handle2) => { FileFinished(id, Data.SoundFileType.Music); lock (syncObject) { m_CurrentFiles.Remove(handle2); } afterPlayed(true); }, false); if (handle != 0) { lock (syncObject) { m_CurrentFiles.Add(handle); } } else { FileFinished(soundFile.Id, Data.SoundFileType.Music); afterPlayed(false); } return(handle); }
public Dictionary <String, List <SoundFile> > constructSoundFiles() { //First off check for null or empty data - don't run this if true if (FilePaths == null || FilePaths.Count() == 0) { return(null); } Dictionary <String, List <SoundFile> > soundData = new Dictionary <string, List <SoundFile> >(); //Now iterate through each filepath foreach (String filePath in FilePaths) { //Split the filepath String[] fileSplit = filePath.Split('\\'); //Get the length of the Sound Effect TimeSpan duration = RecordHelper.getSoundDuration(filePath); SoundFile newFile = new SoundFile(fileSplit[fileSplit.Count() - 1], filePath, duration, fileSplit[fileSplit.Count() - 2]); //Check if we have an existing group or not if (!soundData.ContainsKey(newFile.groupName)) { soundData[newFile.groupName] = new List <SoundFile>(); } soundData[newFile.groupName].Add(newFile); } return(soundData); }
private void saveButton_Click(object sender, EventArgs e) { var sfd = new SaveFileDialog(); sfd.Filter = "MP3 Files (*.mp3)|*.mp3"; if (sfd.ShowDialog() != DialogResult.OK) { return; } if (!SoundFile.Directory.Exists) { SoundFile.Directory.Create(); } if (!SoundFile.Exists) { using (var fileStream = SoundFile.Create()) CacheContext.ExtractResource(Sound.Resource, fileStream); } var destSoundFile = new FileInfo(sfd.FileName); if (!destSoundFile.Directory.Exists) { destSoundFile.Directory.Create(); } SoundFile.CopyTo(destSoundFile.FullName); }
public void Add(SoundFile soundFile) { lock (_soundFiles) { _soundFiles.Add(soundFile); _soundFilesById.Add(soundFile.Id, soundFile); _soundFilesByFileName.Add(soundFile.Filename, soundFile); //Find the list of files of this name if it exists List <SoundFile> files; if (_soundFilesByName.ContainsKey(soundFile.Title)) { files = _soundFilesByName[soundFile.Title]; } else { //Create one if it doesn't files = new List <SoundFile>(); _soundFilesByName.Add(soundFile.Title, files); } //Add the file to the list files.Add(soundFile); } }
public override void Execute() { SoundFile soundFile; try { soundFile = new SoundFile(options.InputPath); } catch (Exception ex) when(ex is IOException or UnauthorizedAccessException or NotSupportedException) { throw new ImuseSequencerException($"Cannot open file: {ex.Message}", ex); } logger.Info($"{soundFile}"); logger.Info($"MIDI: {soundFile.Midi}"); if (soundFile.ImuseHeader != null) { logger.Info($"iMUSE header (MDhd): {soundFile.ImuseHeader}"); } else { logger.Info($"iMUSE header (MDhd): NONE"); } if (options.IncludeEvents || options.IncludeNotes || options.IncludeImuse) { soundFile.Midi.Timeline.ApplyBeatPositions(); logger.Info(""); logger.Info("[b]Events[/]"); foreach (var track in soundFile.Midi.Tracks) { logger.Info(""); logger.Info(track.ToString()); foreach (var evt in track.Events) { bool output = evt.Message switch { NoteOnMessage or NoteOffMessage => options.IncludeNotes, ImuseMessage => options.IncludeImuse || options.IncludeEvents, _ => options.IncludeEvents }; if (output) { logger.Colored($" {evt}", GetColor(evt)); } } } } if (options.IncludeTimeline) { logger.Info(""); logger.Info("[b]Timeline[/]"); foreach (var time in soundFile.Midi.Timeline) { logger.Info(time.ToString()); } } }
public void AddItem(SoundFile soundFileToAdd) { for (int i = 0; i < items.Length; i++) { if (items[i] == null) { items[i] = soundFileToAdd; //add button with info GameObject button = Instantiate(buttonTemplate) as GameObject; button.SetActive(true); button.GetComponent <ButtonListButton>().SetText("Button #" + i); button.transform.SetParent(buttonTemplate.transform.parent, false); //get infos from scriptable objects items[i].soundFile = soundFileToAdd.soundFile; items[i].topic = soundFileToAdd.topic; items[i].namedate = soundFileToAdd.namedate; return; } } }
private IEnumerator Start() { Stopwatch stopWatch = new Stopwatch(); stopWatch.Reset(); stopWatch.Start(); yield return(new WaitForEndOfFrame()); mStateManager = new StateManager <State>(State.NONE); mStateManager.OnPop = OnPopState; mStateManager.OnPush = OnPushState; mStateManager.OnResume = OnResumeState; mStateManager.OnSwitch = OnSwitchState; mUserInterfaceInteriorChangeManager.SetOnRequestMoveToFurnitureStoreListener(OnRequestMoveFurnitureStore); if (SingletonMonoBehaviour <UIPortFrame> .exist()) { SingletonMonoBehaviour <UIPortFrame> .Instance.gameObject.SetActive(false); } mKeyController = new KeyControl(); AudioClip sceneBGM = SoundFile.LoadBGM((BGMFileInfos)104); stopWatch.Stop(); for (int frame = 0; frame < stopWatch.Elapsed.Milliseconds / 60; frame++) { yield return(new WaitForEndOfFrame()); } SoundUtils.SwitchBGM(sceneBGM); SingletonMonoBehaviour <PortObjectManager> .Instance.PortTransition.EndTransition(null); mStateManager.PushState(State.InteriorChange); }
public SimpleSound(SoundFile sample, double sampleFrequency, double volume, double frequency) : base(sampleFrequency, volume, frequency) { this.source = sample.GenerateSource(); this.source.Volume = (float)volume; // No jitter this.source.Pitch = (float)(frequency / this.sampleFrequency); }
protected override void OnLoad(EventArgs e) { stopButton_Click(this, e); //todo: fix if (!SoundFile.Directory.Exists) { SoundFile.Directory.Create(); } if (SoundFile.Exists) { SoundFile.Delete(); } var resourceDefinition = Cache.ResourceCache.GetSoundResourceDefinition(Sound.Resource); if (resourceDefinition != null) { var dataReference = resourceDefinition.Data; byte[] soundData = dataReference.Data; if (Cache is GameCacheGen3) { soundData = ConvertGen3SoundData(Cache, Sound, dataReference.Data); } using (var fileStream = SoundFile.Create()) fileStream.Write(soundData, 0, soundData.Length); } base.OnLoad(e); }
public AudioIrrKlangSession(string filePath) { _soundFile = new SoundFile(filePath); _engine.AddFileFactory(_soundFile); _recorder = new IAudioRecorder(_engine); _path = filePath; //_irrklangEventProxy = new ProxyForIrrklangEvents(this); }
public Audio() { // Load all eating sounds this.omnomnoms = new SoundFile[4]; for (int i = 0; i < this.omnomnoms.Length; i++) { this.omnomnoms[i] = SoundFile.FromOgg("data/sounds/omnomnom" + (i + 1).ToString() + ".ogg"); } }
public SoundObject(SoundFile soundFile, int polyphony, double sliceStart, double sliceEnd, string name = "") { this.soundFile = soundFile; this.polyphony = polyphony; this.sliceStart = sliceStart; this.sliceEnd = sliceEnd; this.name = name; }
void Button3Click(object sender, EventArgs e) { MediaFile mediaFile = new SoundFile("resources\\track.wma"); mediaFile.Play(); System.Threading.Thread.Sleep(3000); mediaFile.Stop(); }
/// <summary> /// Constructor for an AudioSession using the IrrKlang library /// </summary> public AudioIrrKlangSession(string filePath) { Guard.AgainstNull(filePath, "filePath"); _soundFile = new SoundFile(filePath); _engine.AddFileFactory(_soundFile); _recorder = new IAudioRecorder(_engine); _path = filePath; }
public void Clear() { lock (_lock) { _queue.Clear(); _currentSoundFile = null; } }
public SoundLayer Play(SoundFile file, string layer) { // Check whether the layer exists, and create it if it doesn't. SoundLayer playBackLayer = GetLayer(layer) ?? CreateLayer(layer); playBackLayer.Play(file); return(playBackLayer); }
public void Enqueue(SoundFile soundFile) { lock (_lock) { _queue.Enqueue(soundFile); EnsureCurrentSoundFileSet(); } }
/// <summary> /// set media as an asynchronous operation. /// </summary> /// <param name="filename">The filename.</param> /// <returns>Task<SoundFile>.</returns> public async Task <SoundFile> SetMediaAsync(string filename) { CurrentFile = new SoundFile(); CurrentFile.Filename = filename; await StartPlayerAsyncFromAssetsFolder(Application.Context.Assets.OpenFd(filename)); CurrentFile.Duration = TimeSpan.FromSeconds(_player.Duration); return(CurrentFile); }
public override void Execute() { var files = Directory.EnumerateFiles(options.Path, "*.*", new EnumerationOptions { MatchType = MatchType.Simple, RecurseSubdirectories = true }); HashSet <string> events = new(); foreach (var path in files) { string fileName = Path.GetRelativePath(options.Path, path); events.Clear(); SoundFile soundFile; try { soundFile = new SoundFile(path); } catch (MidiFileException ex) { if (options.ListSkipped) { logger.Warning($"{fileName}: {ex.Message}"); } continue; } if (options.Type == PropertyType.ImuseVersion) { logger.Info($"{fileName, -60}: {soundFile.ImuseVersion.GetDisplayName()}"); } else { EnumerateEvents(soundFile, events); if (events.Count == 0) { logger.Info($"{fileName} has no events of this type."); } else { if (options.Type == PropertyType.ImuseUnknown) { logger.Info($"{fileName}:"); foreach (var evt in events) { logger.Info($" {evt}"); } } else { logger.Info($"{fileName}: {String.Join(", ", events)}"); } } } } }
public void PlayClip(AudioClip clip, float volume, float pitch) { if (debug) { Debug.Log("Playing clip " + clip + " at " + volume + " volume and " + pitch + " pitch"); } SoundFile sound = new SoundFile(clip, volume, pitch); soundQueue.Add(sound); }
private void Start() { this.mAudioClip_CommonEnter1 = SoundFile.LoadSE(SEFIleInfos.CommonEnter1); this.mAudioClip_CommonCancel1 = SoundFile.LoadSE(SEFIleInfos.CommonCancel1); this.mAudioClip_CommonCursolMove = SoundFile.LoadSE(SEFIleInfos.CommonCursolMove); this.mAudioClip_CommonEnter2 = SoundFile.LoadSE(SEFIleInfos.CommonEnter2); this.mUIInteriorChangeFurnitureSelector.SetOnSelectFurnitureKindListener(new Action <FurnitureKinds>(this.OnSelectFurnitureKindListener)); this.mUIInteriorChangeFurnitureSelector.SetOnSelectCancelListener(new Action(this.OnSelectCancelListener)); this.mUIInteriorFurniturePreviewWaiter.SetOnBackListener(new Action(this.OnFinishedPreview)); }
public override void ExtractAll(string path) { Directory.CreateDirectory(path); foreach (Entry entry in Entries) { FileStream stream = File.Create(path + "\\" + entry.Name + ".wav"); SoundFile soundFile = new SoundFile(entry, bag); soundFile.Write(stream); stream.Close(); } }
public static float GetLayerVolume(SoundFile.Type layer) { float layerVolume; Instance.m_layerVolumes.TryGetValue(layer, out layerVolume); return layerVolume; }
public static void PlaySoundAsync(SoundFile soundFile) { new Thread(delegate() { Play(soundFile); }).Start(); }
public static void Play(SoundFile soundFile) => Play(soundFile.Path, soundFile.Volume);
public static void SetLayerVolume(SoundFile.Type layer, float volume) { if (volume > 1) volume = 1; if (volume < 0) volume = 0; Instance.m_layerVolumes[layer] = volume; if (layer != SoundFile.Type.Music) { // change volume for all currently existing sounds in the layer, as well as clean up audio list for (int i = 0; i < Instance.m_currentlyPlayingSounds.Count; i++) { SoundFile sound = Instance.m_currentlyPlayingSounds[i]; if (sound.m_source == null) { Instance.m_currentlyPlayingSounds.Remove(sound); } else if (sound.m_type == layer) { sound.m_volume = Instance.m_layerVolumes[layer]; sound.m_source.volume = sound.m_volume; } } } else { AudioManager.Instance.m_currentMusic.m_volume = Instance.m_layerVolumes[layer]; AudioManager.Instance.m_currentMusic.m_source.volume = AudioManager.Instance.m_currentMusic.m_volume; } }
void Awake() { if (Instance == null) { Instance = this; } m_currentlyPlayingSounds = new List<SoundFile>(); m_masterVolume = AudioListener.volume; m_layerVolumes = new Dictionary<SoundFile.Type, float>(); foreach (SoundFile.Type type in System.Enum.GetValues(typeof(SoundFile.Type))) { m_layerVolumes.Add(type, 1); } m_currentMusic = new SoundFile { m_source = gameObject.AddComponent<AudioSource>(), m_paused = false, m_volume = 1, m_type = SoundFile.Type.Music }; m_currentMusic.m_source.loop = true; }
public Sound(string file) { snd = SoundFile.FromOgg(file); }
public static void PlaySoundAtListener(AudioClip clip, SoundFile.Type type) { AudioSource source = Instance.gameObject.AddComponent<AudioSource>(); source.clip = clip; float layerVolume; Instance.m_layerVolumes.TryGetValue(type, out layerVolume); source.volume = layerVolume; source.Play(); Destroy(source, clip.length); Instance.m_currentlyPlayingSounds.Add(new SoundFile { m_source = source, m_volume = source.volume, m_paused = false, m_type = type }); }
public void opensoundfile() { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.DefaultExt = ".mp3"; dialog.Filter = "Sound Files(*.mp3;*.wav)|*.mp3;*.wav"; Nullable<bool> result = dialog.ShowDialog(); if (result == true) { SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(dialog.FileName); if (System.IO.Path.GetExtension(dialog.FileName) == ".wav") { File.Copy(dialog.FileName, Directory.GetCurrentDirectory() + "\\Sounds\\" + System.IO.Path.GetFileName(dialog.FileName), true); file.extension = "wav"; } else if (System.IO.Path.GetExtension(dialog.FileName) == ".mp3") { ConvertMp3 converter = new ConvertMp3(dialog.FileName, Directory.GetCurrentDirectory() + "\\Sounds\\" + file.soundname + ".wav"); converter.ShowDialog(); file.extension = "mp3"; } file.filepath = Directory.GetCurrentDirectory() + "\\Sounds\\" + System.IO.Path.GetFileName(dialog.FileName); sounds.Add(file); System.Windows.Controls.ComboBoxItem SoundMenuItem = new System.Windows.Controls.ComboBoxItem(); Mainwindow.soundselection.Items.Add(SoundMenuItem); } }
void loadsounds() { string path = Directory.GetCurrentDirectory(); string[] filenameswav = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Sounds", "*.wav"); string[] filenamesmp3 = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Sounds", "*.mp3"); for (int o = 0; o < filenamesmp3.Length; o++) { string Sname = filenamesmp3[o]; SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(Sname); ConvertMp3 converter = new ConvertMp3(Sname, Directory.GetCurrentDirectory() + @"\Sounds\" + file.soundname + ".wav", Sname); converter.ShowDialog(); file.filepath = Directory.GetCurrentDirectory() + @"\Sounds\" + file.soundname + ".wav"; file.extension = "wav"; sounds.Add(file); } for (int d = 0; d < filenameswav.Length; d++) { string Sname = filenameswav[d]; SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(Sname); file.filepath = Sname; file.extension = "wav"; sounds.Add(file); } for (int s = 0; s < sounds.Count; s++) { SoundFile sound = sounds[s]; System.Windows.Controls.ComboBoxItem SoundMenuItem = new System.Windows.Controls.ComboBoxItem(); SoundMenuItem.Content = sound.soundname; Mainwindow.soundselection.Items.Add(SoundMenuItem); } CurrentSelectedSound = sounds[0]; // Bleep.mp3 will be the default sound, unless the user picked a different one previously Mainwindow.soundselection.SelectedIndex = 0; }
protected void LoadMusicFile() { Console.WriteLine("Please enter the filename of the music file you want to load:\r\n (this can be any music type your system supports, for instance WAVE, MIDI, MP3, ...)"); string file = Console.ReadLine(); if (file != null && file != "") { mediaFile = new SoundFile(file); } }
public void changesound(int index) { CurrentSelectedSound = sounds[index]; if (isloaded) { al.DeleteSources(1, new int[1] { FSource }); al.DeleteBuffers(1, new int[1] { FBuffer }); FContext.Dispose(); } int[] Buf = new int[1]; FContext = new ContextAL(); FBuffer = FileWAV.LoadFromFile(CurrentSelectedSound.filepath); al.GenSources(1, Buf); FSource = Buf[0]; al.Sourcei(FSource, al.BUFFER, FBuffer); al.Sourcef(FSource, al.PITCH, 1.0f); float newvol = Volume / 100f; al.Sourcef(FSource, al.GAIN, newvol); al.Sourcefv(FSource, al.POSITION, new float[3] { 0, 0, 0 }); al.Sourcefv(FSource, al.VELOCITY, new float[3] { 0, 0, 0 }); al.Listenerfv(al.POSITION, new float[3] { 0, 0, 0 }); al.Listenerfv(al.VELOCITY, new float[3] { 0, 0, 0 }); al.Listenerfv(al.ORIENTATION, new float[6] { 0, 0, -1, 0, 1, 0 }); isloaded = true; }