private async void InitValues() { var awbEntry = WaveformWrapper.WrapperRoot.AcbFile.GetAfs2Entry(WaveformWrapper.WaveformRef.AwbId); if (awbEntry != null) { HcaMetadata metadata = new HcaMetadata(awbEntry.bytes); LoopEnabled = metadata.HasLoopData; LoopStartMs = metadata.LoopStartMs; LoopEndMs = metadata.LoopEndMs; TrackLengthMs = metadata.Milliseconds + 1000; //Declared length can be slightly too short, so extend it by 1 second ValuesChanged(); if (metadata.ValidHcaFile) { awbBytes = awbEntry.bytes; await Task.Run(() => wavStream = HCA.Decode(awbEntry.bytes)); SetLoopOnStream(); CommandManager.InvalidateRequerySuggested(); } } else { Close(); } }
private async void PlayPreview() { #if !DEBUG try #endif { if (!wavStream.IsValid) { wavStream = null; await Task.Run(() => wavStream = HCA.Decode(awbBytes)); SetLoopOnStream(); } if (!audioPlayer.HasAudio(wavStream)) { audioPlayer.SetAudio(wavStream); } audioPlayer.Play(); } #if !DEBUG catch (Exception ex) { MessageBox.Show($"An error occured while processing the PlayPreview command.\n\nDetails:{ex.Message}", $"PlayPreview failed", MessageBoxButton.OK, MessageBoxImage.Error); } #endif }
public static void TrueLoadSong(string key) { if (!SongList.ContainsKey(key) && LoadSongList.ContainsKey(key)) { WavStream wav = new WavStream(); wav.load(LoadPath + LoadSongList[key]); SongList.Add(key, wav); } }
public static void LoadSong(string key, string path, double defaultVolume = 1) { #if DEBUG GhostLoadSong(key, path, defaultVolume); #else WavStream wav = new WavStream(); wav.load(LoadPath + path); SongList.Add(key, wav); DefaultSongVolume.Add(key, defaultVolume); #endif }
public async System.Threading.Tasks.Task <ActionResult> Post(string culture) { /* * foreach (String key in Request.Files) * { * HttpPostedFileBase f = Request.Files[key]; * Response.Write($"filename {f.FileName} size {f.ContentLength}"); * } */ if (String.IsNullOrEmpty(culture) || Request.Files.Count != 1) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var file = Request.Files[0]; Response.Buffer = false; Response.ContentType = "text/plain"; using (WavStream wavStream = await new WavAudioConverter(configuration).ConvertAsync(file.InputStream)) { /* * ShortPhrase mode: An utterance up to 15 seconds long. As data is sent to the server, * the client receives multiple partial results and one final best result. * * LongDictation mode: An utterance up to 10 minutes long. As data is sent to the server, * the client receives multiple partial results and multiple final results, based on where the * server indicates sentence pauses. */ PhraseMode mode = (wavStream.AudioLength > MaxShortAudioLength ? PhraseMode.LongDictation : PhraseMode.ShortPhrase); await new AudioDecoderService(configuration).DecodeAudioAsync(wavStream, culture, mode, (args) => { Response.Write(JsonConvert.SerializeObject(args)); Response.Write(Environment.NewLine); return(Response.FlushAsync()); }, (args) => { Response.Write(JsonConvert.SerializeObject(args)); Response.Write(Environment.NewLine); return(Response.FlushAsync()); }); } return(null); }
public unsafe Song LoadSong(SongData song_data) { var wav_stream = new WavStream(); fixed(byte *p = song_data.Data) { var ptr = (IntPtr)p; wav_stream.loadMem(ptr, (uint)song_data.Data.Length, aCopy: true); } var song = new Song(wav_stream) { Id = song_data.Id }; return(song); }
internal Song(WavStream stream) { song_stream = stream; }