/// <summary> /// Builds the content for the source audio. /// </summary> /// <param name="input">The audio content to build.</param> /// <param name="context">Context for the specified processor.</param> /// <returns>The built audio.</returns> public override SoundEffectContent Process( AudioContent input, ContentProcessorContext context) { if (input == null) { throw new ArgumentNullException(nameof(input)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } var profile = AudioProfile.ForPlatform(context.TargetPlatform); var finalQuality = profile.ConvertAudio(context.TargetPlatform, Quality, input); if (Quality != finalQuality) { context.Logger.LogMessage( "Failed to convert using \"{0}\" quality, used \"{1}\" quality", Quality, finalQuality); } return(new SoundEffectContent( input.Format.NativeWaveFormat, input.Data, input.DataLength, input.LoopStart, input.LoopLength, input.Duration)); }
/// <summary> /// Builds the content for the source audio. /// </summary> /// <param name="input">The audio content to build.</param> /// <param name="context">Context for the specified processor.</param> /// <returns>The built audio.</returns> public override SongContent Process(AudioContent input, ContentProcessorContext context) { // The xnb name is the basis for the final song filename. string songInputFile = context.OutputFilename; // Convert and write out the song media file. var profile = AudioProfile.ForPlatform(context.TargetPlatform); var finalQuality = profile.ConvertStreamingAudio( context.TargetPlatform, Quality, input, songInputFile, out string songOutFile); // Let the pipeline know about the song file so it can clean things up. context.AddOutputFile(songOutFile); if (Quality != finalQuality) { context.Logger.LogMessage( "Failed to convert using \"{0}\" quality, used \"{1}\" quality", Quality, finalQuality); } // Return the XNB song content. string dirPath = Path.GetDirectoryName(context.OutputFilename) + Path.DirectorySeparatorChar; string filePath = PathHelper.GetRelativePath(dirPath, songOutFile); return(new SongContent(filePath, input.Duration)); }
public void LoadProfile(AudioProfile profile) { audioProfileList.Add(profile.profileKey, new Dictionary <string, AudioData>()); foreach (AudioData data in profile.audioData) { audioProfileList[profile.profileKey].Add(data.accessKey, data); } }
public async Task <ActionResult> CreateProfile(AudioProfile model) { if (ModelState.IsValid) { var profileId = await AudioIdentificationService.CreateProfile(model); return(RedirectToAction("EnrollProfile", new { id = profileId })); } return(View(model)); }
public ShootingProcessor(AudioSystem system, AudioProfile profile) { this.system = system; this.profile = profile; foreach (ShooterProcessor shooterSystemInstance in this.system.WorldSystem.ShooterSystem.Instances) { shooterSystemInstance.Fire += OnShooterFire; } this.system.WorldSystem.ShooterSystem.InstanceDeployed += OnShooterDeployed; }
private void LevelReady(System.Object e) { audioManager.clearLevelAudio(); bool getStart = true; if (PlayerPrefs.GetInt(SaveKeys.LEVEL) == View.instance.currentLevel && PlayerPrefs.GetString(SaveKeys.CHECK_POINT) != "") { getStart = false; } PlayerPrefs.SetInt(SaveKeys.LEVEL, View.instance.currentLevel); foreach (GameObject checkpoint in GameObject.FindGameObjectsWithTag("CheckPoint")) { if (!getStart && checkpoint.GetComponent <CheckPoint>().ID == PlayerPrefs.GetString(SaveKeys.CHECK_POINT)) { SetCheckPoint(checkpoint.GetComponent <CheckPoint>()); } if (getStart && checkpoint.GetComponent <CheckPoint>().startPoint) { SetCheckPoint(checkpoint.GetComponent <CheckPoint>()); } } if (currentCheckpoint) { Camera.main.GetComponent <LevelCamera>().setPanPosition(currentCheckpoint.CameraPanPosition); } else { Debug.LogError("No starting spawn found, have you rememberd to set the flag in your checkpoint?"); } currentLevelProfile = Resources.Load <AudioProfile>("level" + View.instance.currentLevel); audioManager.LoadProfile(currentLevelProfile); Controller.instance.Dispatch(EngineEvents.ENGINE_LOAD_FINISH); if (!View.instance.mainMenuOpen) { Controller.instance.Dispatch(EngineEvents.ENGINE_GAME_INIT); } }
private async Task RegisterRoryMcIlroy() { var profile = new AudioProfile { Name = "Rory McIlroy", SelectedLocale = "en-us" }; profile.Id = await CreateProfile(profile); var url = $"{Configuration["AudioAnalyticsAPI"]}identificationProfiles/{profile.Id}/enroll"; var key = Configuration["AudioAnalyticsKey"]; var req = WebRequest.Create("https://cognitiveservice.blob.core.windows.net/fakes/Rory%20McIlroy.wav"); using (var stream = req.GetResponse().GetResponseStream()) { await CognitiveServicesHttpClient.HttpPostAudio(stream, url, key); } }
public async Task <Guid> CreateProfile(AudioProfile profile) { var url = Configuration["AudioAnalyticsAPI"] + "identificationProfiles"; var key = Configuration["AudioAnalyticsKey"]; var tableName = Configuration["AudioIdentificationProfileTable"]; var payload = $"{{\"locale\" : \"{ profile.SelectedLocale.ToLower() }\"}}"; var byteData = Encoding.UTF8.GetBytes(payload); using (var content = new ByteArrayContent(byteData)) { var response = await CognitiveServicesHttpClient.HttpPost(content, url, key); var responseBytes = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { var result = JSONHelper.FromJson <IdentificationProfile>(responseBytes); profile.Id = Guid.Parse(result.IdentificationProfileId); profile.RowKey = profile.Id.ToString(); profile.PartitionKey = profile.Id.ToString(); await CloudTableService.Insert(profile, tableName); return(profile.Id); } throw new Exception($"Failed request : { responseBytes } "); } }
public AudioProcessor(AudioSystem system, GameObject instance) : base(system, instance) { this.profile = new AudioProfile(GameObject); SubProcessors.Add(new ShootingProcessor(system, this.profile)); }
public override SongContent Process(AudioContent input, ContentProcessorContext context) { var outputFilename = Path.ChangeExtension(context.OutputFilename, "ogg"); var songContentFilename = PathHelper.GetRelativePath(Path.GetDirectoryName(context.OutputFilename) + Path.DirectorySeparatorChar, outputFilename); context.AddOutputFile(outputFilename); // Use the ogg-file as-is if (Path.GetExtension(input.FileName) == "ogg") { File.Copy(input.FileName, outputFilename); return((SongContent)_songContentConstructor.Invoke(new object[] { songContentFilename, input.Duration })); } // Prepare some useful paths and checks var hashFile = Path.ChangeExtension(input.FileName, "hash"); var oggFile = Path.ChangeExtension(input.FileName, "ogg"); var oggFileExists = File.Exists(oggFile); // Compare a previous hash, if there is one. var currentHash = CalculateSHA1(input.FileName); string previousHash = null; if (File.Exists(hashFile) && oggFileExists) { previousHash = File.ReadAllText(hashFile); } else { File.WriteAllText(hashFile, currentHash); } // Determine if we can re-use a previously generated ogg-file if (oggFileExists && previousHash == currentHash) { File.Copy(oggFile, outputFilename); } else { var conversionQuality = AudioProfile.ForPlatform(TargetPlatform.DesktopGL) .ConvertStreamingAudio(TargetPlatform.DesktopGL, Quality, input, ref outputFilename); if (Quality != conversionQuality) { context.Logger.LogMessage("Failed to convert using \"{0}\" quality, used \"{1}\" quality", Quality, conversionQuality); } if (oggFileExists) { File.Delete(oggFile); } File.Copy(outputFilename, oggFile); } return((SongContent)_songContentConstructor.Invoke(new object[] { songContentFilename, input.Duration })); }
public Profile(FrameProfile frameProfile, AudioProfile audioProfile, int frameLimit = 1_000, float frameRate = 30, int frameCountDownscale = 1, bool lastFrameBlank = true)
static void Main(string[] args) { Console.WriteLine("WmaEncoder.Net"); if (args.Length < 2) { PrintUsageHelp(); return; } EncodingParameters encodingParams = Parser.ParseCommandLine(args); // make sure they've at least specified a filename! if (string.IsNullOrWhiteSpace(encodingParams.InputFilename)) { Console.WriteLine("No input file specified"); return; } if (string.IsNullOrWhiteSpace(encodingParams.OutputFilename) && string.IsNullOrWhiteSpace(encodingParams.OutputFolder)) { Console.WriteLine("No output filename or folder specified"); return; } // next, try to open the specified filename. If we can't open it, no need to bother with anything else MediaItem mi = null; try { mi = new MediaItem(encodingParams.InputFilename); } catch (InvalidMediaFileException e) { Console.WriteLine("Error opening source file: " + e.Message); return; } // if an output filename is specified, use that. Otherwise, try to use the output folder if (!string.IsNullOrWhiteSpace(encodingParams.OutputFilename)) { mi.OutputFileName = Path.GetFileName(encodingParams.OutputFilename); } else { mi.OutputFileName = Path.GetFileName(encodingParams.InputFilename); } if (!string.IsNullOrEmpty(encodingParams.Title)) { mi.Metadata["Title"] = encodingParams.Title; } if (!string.IsNullOrEmpty(encodingParams.Album)) { mi.Metadata["WM/AlbumTitle"] = encodingParams.Album; } if (!string.IsNullOrEmpty(encodingParams.Artist)) { mi.Metadata["Author"] = encodingParams.Artist; } if (encodingParams.TrackNumber > 0) { mi.Metadata["WM/TrackNumber"] = Convert.ToString(encodingParams.TrackNumber); } if (!string.IsNullOrEmpty(encodingParams.Genre)) { mi.Metadata["WM/Genre"] = encodingParams.Genre; } if (!string.IsNullOrEmpty(encodingParams.Year)) { mi.Metadata["WM/Year"] = encodingParams.Year; } ObservableCollection <AudioProfile> codecProfiles = new ObservableCollection <AudioProfile>(); Microsoft.Expression.Encoder.Profiles.LocalProfiles.EnumerateAudioCodecs(codecProfiles); AudioCodec selectedCodec = AudioCodec.Wma; if (encodingParams.Quality == 100) { selectedCodec = AudioCodec.WmaLossless; if (encodingParams.Bitrate < 0) { encodingParams.Bitrate = 44100; } } else { selectedCodec = AudioCodec.Wma; if (encodingParams.Bitrate < 0) { encodingParams.Bitrate = 128; } } // find the correct codec AudioProfile selectedAudioProfile = null; foreach (AudioProfile audioProfile in codecProfiles) { if (encodingParams.Quality > 0) { if (encodingParams.Quality == 100) { if ((audioProfile.BitsPerSample == 16) && (audioProfile.Codec == selectedCodec) && (audioProfile.Channels == 2) && (audioProfile.SamplesPerSecond == encodingParams.Bitrate)) { selectedAudioProfile = audioProfile; break; } } else if (audioProfile.Bitrate is Microsoft.Expression.Encoder.Profiles.VariableQualityBitrate /* (audioProfile.Bitrate.IsVariableBitrate == true) */) { Microsoft.Expression.Encoder.Profiles.VariableQualityBitrate vqb = (Microsoft.Expression.Encoder.Profiles.VariableQualityBitrate)audioProfile.Bitrate; if (vqb.Quality == encodingParams.Quality) { selectedAudioProfile = audioProfile; break; } } } else { if ((audioProfile.BitsPerSample == 16) && (audioProfile.Codec == selectedCodec) && (audioProfile.Channels == 2) && (audioProfile.Bitrate.BitrateValue == encodingParams.Bitrate)) { selectedAudioProfile = audioProfile; break; } } } if (selectedAudioProfile != null) { mi.OutputFormat.AudioProfile = selectedAudioProfile; } else { throw new Exception("Unable to find a matching codec profile"); } Console.WriteLine("Initializing Expression Encoder 4 SDK..."); Job job = new Job(); job.MediaItems.Add(mi); job.CreateSubfolder = false; if (string.IsNullOrWhiteSpace(encodingParams.OutputFolder)) { job.OutputDirectory = Path.GetDirectoryName(Path.GetFullPath(encodingParams.OutputFilename)); } else { DirectoryInfo di = new DirectoryInfo(encodingParams.OutputFolder); job.OutputDirectory = di.FullName; } job.EncodeProgress += new EventHandler <EncodeProgressEventArgs>(job_EncodeProgress); job.Encode(); }
public IActionResult CreateProfile() { var model = new AudioProfile(); return(View(model)); }