How to use AVAudioPlayerNode with AVMutableComposition - core-audio

The AVAudioEngine and related AVAudioNode objects seem to be quite powerful for audio processing but it's difficult to see how to automate parameter changes with them. I'm sure there must be something more effective than manually using a Timer to change values, as a crude example.
AVMutableAudioMixInputParameters includes a method setVolumeRampFromStartVolume:toEndVolume:timeRange: but I cannot see how I could integrate that with AVAudioPlayerNode (connected with AVAudioEffectNodes) and use that method to fade the volume over time. Instead, I have only seen examples of AVMutableAudioMixInputParameters working with AVMutableCompositioninstances and none of them include AVAudioNode objects.
Can anyone post or link to some code samples that combine the use of AVAudioNodes with setVolumeRampFromStartVolume:toEndVolume:timeRange: or explain best practices for automating parameter changes on a node over time?
Many thanks

The AVAudioEngine is a real-time engine, but AVMutableComposition seems to be a non-real-time object. Thus incompatible. An alternative is to build and insert your own fader real-time AUAudioUnit node..

Related

Pitch Shift in p5.js

I've been racking my brain on how to do a pitch shift in p5.js, and I've found documentation for a rate change (pitch and speed together), as well as a speed change without changing pitch. I was trying to experiment with having those run simultaneously, but it appears rate() is only available for p5.SoundFile and speed is only available for p5.MediaElement.
I was wondering if anyone had run across a way to extend functionality from one object to another, or if there was a way to manually extend the functionality somewhere in custom code.
Option 1. Switch to ToneJS
ToneJS is another library that wraps the browser's Audio API and it has a built in PitchShift effect. There's nothing special about p5.sound that makes it better or worse for use with p5.js except maybe that it follows some of the same conventions.
Option 2. Write a Custom Effect
p5.Sound provides a base class p5.Effect which could be used to implement a pitch shift effect however, this would be a pretty challenging project unless you have experience with digital signal processing and the underlying browser Audio API. Here's a Wikipedia page on the algorithm in question.

react-addons-transition-group's `componentWillLeave` equivalent for React Native??

The componentWillLeave feature and the corresponding callback is a powerful feature I haven't seen in RN. Without it, you're always forced into producing very crappy code using additional states to make sure an element stays on the page/phone until its animation is complete, when ideally some boolean state from redux simply triggers the removal of the element while respecting its willleave animation.
So does anyone have any ideas how to accomplish this consistently in RN without having to write custom code every time to make sure the element stays rendered until you animate it away??
I know this is an old question, but I just landed here from a google search on the topic so I'll give my 2 cents on it.
This library should represent a 1:1 replacement for react-addons-transition-group for RN and comes with support for componentWillLeave method you can implement. It supports both componentWillEnter and componentWillLeave.
Link to the library: react-native-transitiongroup

Finding an object using tango device

I want to create a small project using google project tango where I want to identify different objects like chairs and tables. I am using area learning mechanism. I want to know what else I need to use to identify different objects in 3D space.
Object recognition isn't really a trivial problem and, depending on your approach and how flexible you want it to be, can become very involved and complicated. I would strongly recommend you do some research and read up on the topic first and make sure you have a good grasp on the basics.
That being said, there are existing Android projects available on GitHub, etc. that are capable of recognising various objects and I would recommend you have a look at those.
By the way, is there a specific reason you want to implement this on a Tango? Unless you plan on using the point cloud data instead of image data, object recognition should be able to work on a normal, non-Tango device as well.

write only stream

I'm using joliver/EventStore library and trying to find a way of how to get a stream not reading any events from it.
The reason is that I want just to write some events into that store for specific stream without loading all 10k messages from it.
The way you're expected to use the store is that you always do a GetById first. Even if you new up an Aggregate and Save it, you'll see in the CommonDomain EventStoreRepository that it will first correlate it with the existing data.
The key reason why a read is needed first is that the infrastructure needs to work out how many events have gone before to compute the new commit sequence number.
Regarding your citing of your example threshold that makes you want to optimize this away... If you're really going to have that level of events, you'll already be into snapshotting territory as you'll need to have an appropriately efficient way of doing things other than blind write too.
Even if you're not intending to lean on snapshotting, half the benefit of using EventStore is that the facility is buitl in for when you need it.

Organizing GUI code

My question has two parts:
Does anyone have any tips or references to some documentation on the web about how to write GUI code that is easy to read, write, and maintain?
Example.
I find that the more extensive my GUI forms become, I end up with a long list of fairly short event handler methods. If I try to add any private helper methods, they just get lost in the shuffle, and I constantly have to scroll around the page to follow a single line of thought.
How can I easily manage settings across the application?
Example.
If the user selects a new item in a drop-down list, I might need to enable some components on the GUI, update an app config file, and store the new value in a local variable for later. I usually opt to not create event handlers for all the settings (see above), and end up with methods like "LoadGUISettings" and "SaveGUISettings", but then I end up calling these methods all over my code, and it runs through a lot of code just to update very few, if any, actual changes.
Thanks!
Some guidelines for the first question, from an OO perspective:
Break up large classes into smaller ones. Does that panel have a bunch of fairly modular subpanels? Make a smaller class for each subpanel, then have another, higher-level class put them all together.
Reduce duplication. Do you have two trees that share functionality? Make a superclass! Are all of your event handlers doing something similar? Create a method that they all call!
Second question. I see two ways of doing this:
Listeners. If many components should respond to a change that occured in one component, have that component fire an event.
Global variables. If many components are reading and writing the same data, make it global (however you do that in your chosen language). For extra usefulness, combine the two approaches and let components listen for changes in the global data object.
If you're using WPF, you might want to read the Composite Application Guideance for WPF.
It discusses many of these topics (as well as many others). The main goal of that guideance is to make large scale applications in a flexible, maintainable manner.
You should definitely look at Jeremy Miller's guide to rich client design. It is incomplete, but I believe he is writing a book on the subject.
Another blog you should check out is Rich Newman's. He is writing about Composite Application Block which is a MS best practice guide on how to structure rich clients.
You can also read this book which is only a very light read but gives you some good ideas.

Resources