public void Init(string tokenEndpoint, string ttsEndpoint, string key) { if (tokenEndpoint == null || ttsEndpoint == null || key == null) { throw new Exception("Config Error"); } AuthClient authenticationClient = null; if (tokenEndpoint != null) { authenticationClient = new AuthClient(tokenEndpoint, key); } Synthesizer = new Synthesizer(new Uri(ttsEndpoint), Synthesizer.OutputFormats.Raw24Khz16BitMonoPcm, authenticationClient); Synthesizer.AudioAvailabled += Synthesizer_OnAudioAvailable; Synthesizer.Failed += Synthesizer_OnError; Synthesizer.QueueChanged += Synthesizer_QueueChanged; WaveFilters = new List <IWaveFilter>(); volumeFilter = new VolumeFilter(); WaveFilters.Add(volumeFilter); //IsPlaying = false; //PlayCompletedEvent = new ManualResetEvent(false); }
private void Microphone_NewFrame(object sender, Accord.Audio.NewFrameEventArgs eventArgs) { _MicrophoneSignal = eventArgs.Signal; float n = 1f; var volume = new VolumeFilter(n); volume.ApplyInPlace(_MicrophoneSignal); }
public async Task <IActionResult> SetVolumeAsync([FromBody] VolumeFilter volumeFilter) { await _playerManager.SetVolumeAsync(volumeFilter); _signalRHelper.SetVolume(volumeFilter.Volume); return(Json(new { Succeed = true })); }
private static Task <TakeRateData> ListVolumeData(IDataContext context, Volume forVolume) { if (forVolume.Document is EmptyOxoDocument) { return(new TakeRateData()); } return(context.Volume.ListVolumeData(VolumeFilter.FromVolume(forVolume))); }
/// <summary> /// Allows creation of an on-demand snapshot of volumes /// <para> /// If multiple volumes are provided, multiple name patterns are /// required, where the index of the list of items are related. For /// example, the name pattern at index <c>3</c> of the /// <c>namePatterns</c> parameter will be applied to the volume /// specified at index <c>3</c> of the <c>parentVolumeGuids</c> list. /// </para> /// </summary> /// <param name="parentVolumeGuids"> /// List of unique identifiers for all volumes for which to create a /// snapshot /// </param> /// <param name="namePatterns"> /// List of naming patterns for volume snapshots. Options of the /// <c>strftime</c> function are available to format time and the /// variable <c>%v</c> that will be translated to the volume name. /// </param> /// <param name="expirationSeconds"> /// The number of seconds after snapshot creation when the snapshots /// will be automatically deleted /// </param> /// <param name="retentionSeconds"> /// The number of seconds before a user can delete the snapshots. /// </param> /// <returns></returns> public Volume CreateSnapshot( Guid[] parentVolumeGuids, string[] namePatterns, long?expirationSeconds = null, long?retentionSeconds = null) { // prepare parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("parentVvUID", parentVolumeGuids, false); parameters.Add("snapNamePattern", namePatterns, false); parameters.Add("consistencyLevel", SnapshotConsistencyLevel.VV, false); parameters.Add("roSnap", true, false); parameters.Add("expirationSec", expirationSeconds, false); parameters.Add("retentionSec", retentionSeconds, false); TokenResponse tokenResponse = RunMutation <TokenResponse>( @"createSnap", parameters); bool deliverySuccess = DeliverToken(tokenResponse); if (!deliverySuccess) { throw new Exception("Snapshot creation failed"); } // query for the snapshot VolumeFilter filter = new VolumeFilter(); filter.Guid = new GuidFilter(); filter.Guid.MustEqual = tokenResponse.WaitOn; DateTime start = DateTime.UtcNow; while (true) { Thread.Sleep(2000); VolumeList list = GetVolumes(null, filter, null); if (list.FilteredCount > 0) { return(list.Items[0]); } // check if we should time out. double duration = (DateTime.UtcNow - start).TotalSeconds; double remaining = SNAPSHOT_CREATE_WAITTIME_SEC - duration; if (remaining <= 0) { throw new Exception("Snapshot creation timed out"); } } }
/// <summary> /// Returns a list of configured <b>NebVolume</b> instances based on the /// provided page and filter information. /// </summary> /// <param name="page"> /// The requested page from the server. This is an optional argument /// and if omitted the server will default to returning the first page /// with a maximum of <c>100</c> items. /// </param> /// <param name="filter"> /// A filter object to filter the volumes on the server. If omitted, /// the server will return all objects as a paginated response. /// </param> /// <param name="sort"> /// A sort definition object to sort the volume objects on supported /// properties. If omitted objects are returned in the order as they /// were created in. /// </param> /// <returns>A paginated list of volumes</returns> public VolumeList GetVolumes( PageInput page = null, VolumeFilter filter = null, VolumeSort sort = null) { GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("page", page, true); parameters.Add("filter", filter, true); parameters.Add("sort", sort, true); // this should return exactly one item. return(RunQuery <VolumeList>(@"getVolumes", parameters)); }
public async Task <ActionResult <string> > GetAsync(int id) { // TODO: Test code for quickly verifying changes. ComicVineService comicVineService = new ComicVineService(); //var testVolume = await comicVineService.GetVolume("4050-796"); VolumeFilter filter = new VolumeFilter() { Name = "Teen Titans" }; VolumeSort sort = new VolumeSort(); ComicSearch comicSearch = new ComicSearch() { VolumeFilterCriteria = filter, VolumeSortCriteria = sort }; var testVolumes = await comicVineService.SearchComics(comicSearch); var testOneIssue = await comicVineService.GetIssue(30000); var testOneMore = await comicVineService.GetIssue(0); return("Testing"); //var moreTest = testVolumes.Where(x => x.Deck != null); //return testVolumes[0].Deck == null ? testVolumes[0].Description : testVolumes[0].Deck.ToString(); /* * DALConfig config = new DALConfig(); * var collectionDb = config.GetMongoDatabase(); * collectionDb.DropCollection("User"); * * UserRepository userRepository = new UserRepository(); * ComicCollectionRepository comicCollectionRepository = new ComicCollectionRepository(); * CollectedVolumeRepository collectedVolumeRepository = new CollectedVolumeRepository(); * * userRepository.Save(new ComicAPI.Models.User() { Name = "Shannon" }); * userRepository.Save(new ComicAPI.Models.User() { Name = "Tony Stark" }); * * var test = userRepository.GetAll(); * * return "Testing!"; */ }
/// <summary> /// Allows creating a read/writeable clone of a volume or snapshot /// <para> /// Allows the creation of a volume clone from a base volume or /// snapshot. Clones are read and writeable copies of another volume. /// Clones can be used to quickly instantiate copies of data and data /// for recovery purposes when applications require read/write access /// for copy operations. /// </para> /// </summary> /// <param name="name"> /// The human readable name for the volume clone /// </param> /// <param name="volumeGuid"> /// The unique identifier for the volume or snapshot from which to /// create the clone. /// </param> /// <returns></returns> public Volume CreateClone(string name, Guid volumeGuid) { CreateCloneInput input = new CreateCloneInput(); input.Name = name; input.VolumeGuid = volumeGuid; // prepare parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("input", input, false); TokenResponse tokenResponse = RunMutation <TokenResponse>( @"createClone", parameters); bool deliverySuccess = DeliverToken(tokenResponse); if (!deliverySuccess) { throw new Exception("Clone creation failed"); } // query for the clone VolumeFilter filter = new VolumeFilter(); filter.Name = new StringFilter(); filter.Name.MustEqual = name; DateTime start = DateTime.UtcNow; while (true) { Thread.Sleep(2000); VolumeList list = GetVolumes(null, filter, null); if (list.FilteredCount > 0) { return(list.Items[0]); } // check if we should time out. double duration = (DateTime.UtcNow - start).TotalSeconds; double remaining = SNAPSHOT_CREATE_WAITTIME_SEC - duration; if (remaining <= 0) { throw new Exception("Clone creation timed out"); } } }
/// <summary> /// Compiles a single filter from a list of filters by combining them /// with a logical AND /// </summary> /// <param name="filters"> /// List of filters to combine /// </param> /// <returns></returns> private VolumeFilter GenerateFilter(List <VolumeFilter> filters) { VolumeFilter result = null; foreach (VolumeFilter filter in filters) { if (result == null) { result = filter; continue; } filter.And = result; result = filter; } return(result); }
private void adjustVolume(float value) { // First, we rewind the stream stream.Seek(0, SeekOrigin.Begin); // Then we create a decoder for it decoder = new WaveDecoder(stream); var signal = decoder.Decode(); // We apply the volume filter var volume = new VolumeFilter(value); volume.ApplyInPlace(signal); // Then we store it again stream.Seek(0, SeekOrigin.Begin); encoder = new WaveEncoder(stream); encoder.Encode(signal); }
public async Task <VolumesResponse> GetVolumes(VolumeFilter filter, VolumeSort sort) { return(await GetMany <VolumesResponse, VolumeSort, VolumeFilter>("volumes", sort, filter)); }
/// <summary> /// Allows creation of a new volume /// </summary> /// <param name="input"> /// Configuration definition for the new volume /// </param> /// <returns>The created volume</returns> public Volume CreateVolume(CreateVolumeInput input) { // setup parameters GraphQLParameters parameters = new GraphQLParameters(); parameters.Add("input", input); TokenResponse tokenResponse = RunMutation <TokenResponse>( @"createVolumeV3", parameters); RecipeRecordIdentifier identifier = DeliverTokenV2(tokenResponse); if (identifier == null) { throw new Exception("Uncomprehensive information returned from server"); } // wait for recipe completion DateTime start = DateTime.UtcNow; // recipe filter NPodRecipeFilter filter = new NPodRecipeFilter(); filter.NPodGuid = identifier.NPodGuid; filter.RecipeGuid = identifier.RecipeGuid; while (true) { Thread.Sleep(1000); // query for recipes RecipeRecordList recipes = GetNPodRecipes(filter); // if there is no record in the cloud wait a few more seconds // this case should not exist. TODO: Remove in next version. if (recipes.Items.Length == 0) { continue; } // based on the query there should be exactly one RecipeRecord recipe = recipes.Items[0]; // execution failed if (recipe.State == RecipeState.Failed) { string error = string.Concat("volume creation failed", recipe.Status); throw new Exception(error); } // execution completed if (recipe.State == RecipeState.Completed) { VolumeFilter volumeFilter = new VolumeFilter(); volumeFilter.Guid = new GuidFilter(); volumeFilter.Guid.MustEqual = tokenResponse.WaitOn; VolumeList list = GetVolumes(null, volumeFilter, null); if (list.FilteredCount >= 0) { return(list.Items[0]); } } // still ongoing double duration = (DateTime.UtcNow - start).TotalSeconds; double timeRemaining = NPOD_CREATE_WAITTIME_SEC - duration; if (timeRemaining <= 0) { throw new Exception("Snapshot creation timed out"); } } }
/// <summary> /// Performs execution of the command /// </summary> protected override void ProcessRecord() { try { List <VolumeFilter> filters = new List <VolumeFilter>(); VolumeFilter snapsFilter = new VolumeFilter(); snapsFilter.BaseOnly = !OnlySnapshots.IsPresent && !IncludeSnapshots.IsPresent; filters.Add(snapsFilter); if (OnlySnapshots.IsPresent) { VolumeFilter f1 = new VolumeFilter(); f1.SnapshotsOnly = true; filters.Add(f1); } if (ParameterPresent("Guid")) { VolumeFilter f = new VolumeFilter(); f.Guid = new GuidFilter(); f.Guid.MustEqual = Guid; filters.Add(f); } if (ParameterPresent("Name")) { VolumeFilter f = new VolumeFilter(); f.Name = new StringFilter(); f.Name.MustEqual = Name; filters.Add(f); } if (ParameterPresent("NPod")) { VolumeFilter f = new VolumeFilter(); f.NPodGuid = new GuidFilter(); f.NPodGuid.MustEqual = NPod.Guid; filters.Add(f); } if (ParameterPresent("ParentVolume")) { VolumeFilter f = new VolumeFilter(); f.ParentGuid = new GuidFilter(); f.ParentGuid.MustEqual = ParentVolume.Guid; filters.Add(f); // make sure that snapshots are included foreach (VolumeFilter ef in filters) { if (ef.BaseOnly.HasValue) { ef.BaseOnly = false; } } } // convert to filter VolumeFilter filter = GenerateFilter(filters); // Compile a sort direction from the provided input // Default sort direction is Ascending VolumeSort sort = new VolumeSort(); sort.Name = SortDirection.Ascending; PageInput page = PageInput.First; VolumeList list = Connection.GetVolumes(page, filter, sort); foreach (Volume item in list.Items) { WriteObject(item); } while (list.More) { // advance the page page.Page = page.Page + 1; list = Connection.GetVolumes(page, filter, sort); foreach (Volume item in list.Items) { WriteObject(item); } } } catch (AggregateException exceptions) { foreach (Exception ex in exceptions.InnerExceptions) { WriteError(ex); } } catch (Exception ex) { WriteError(ex); } }