I'm working on a toy with multiple "touch areas" which serve as inputs to my synth.
Using an oscillatorBank I can start and stop notes easily.
In regular keyboards there's only 1 key for each Midi note, so "retriggering" a note requires the musician to lift their finger, even if only briefly allowing one to call .stop() and then .start() on the note.
The scenario I'm working on is when the note is held down, but is then triggered again on another "touch area". Could I somehow "retrigger" the "attack" sound for that note? Should I start and stop the player? Ideally I would call
oscillator.restart(noteNumber: )
but that doesn't exist that I know of.
Many thanks.
Seems like a simple wrapper for stop(noteNumber:) and start(noteNumber:) that you could set up in an extension.
Related
I have a volume slider in my application that I'd like to have a sound effect play when the user changes the value. The standard valueChanged event works well here, and I'd like to use it in conjunction with a touches ended signal to trigger the sound at the end. Is there a control event here that I'm missing that would run my method when the touches finish? It doesn't seem like there is a UIControlEventTouchesEnded...
Some code samples would help, but I guess you're looking for UIControlEventTouchUpInside. I'm not sure, if it works with a slider.
One possibility would be to set the slider's continuous to NO. Now it emits just one valueChanged event, namely when the user is all finished - just what you want to know.
Im trying to find the best way to avoid having tiny UI lockups after certain events in my app. For example here are two cases where i have come across mini-lockups:
I have a button that when pressed loads a local mp3 file (around 20-30mb) using AVAudioPlayer, calls the prepareToPlay method and then plays the audio file. The issue is that the button has the showsTouchWhenHighlighted flag set to yes and after pressing it it stays highlighted until the audio file begins playing which could take 1-3 secs.
Another similar example is using a navbar button to sort and reload the table data. There is a very short but noticeable lockup where the button remains highlighted until the table has reloaded.
Can anyone suggest a good approach to minimizing/eliminating these mini lockups? I didnt really come across any code to achieve this in any of the books/tutorials i read that dealt with tableviews and avaudioplayer. Should i be launching these actions on different threads?
thx
For number 1, your best bet is to load the item on a background thread and inform the user that you're doing so (either via a loading HUD or some other indicator). The simplest way of doing this will be to use - (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg;. If you're running iOS 4.0 + you may want to look into executing block callbacks and see if they will work for you.
For number 2, perform the sorting on the background thread or change your sorting method (consider using a sorted data structure rather than resorting after inserts?). reloadData should occur only on the main thread.
I'm an iPhone noob myself, but it sounds like your code is stuck doing synchronous actions, which will guarantee that your UI gets locked up until the action is done executing.
Although I don't have an explicit answer, look for asynchronous options to perform these actions as they will not lockup your UI. These are usually achieved through using threads or deferred objects. From my experience so far w/ Objective-C, most actions your program neds to take can be achieved through async actions.
I have written code so that technically there should be two MPMoviePlayerControllers within the same view, both ready to play an audio file. What always happens is that one pops up and disappears, and the other comes up and stays, and is fully useable.
Any idea why one disappears? I'm not trying to play two at once, just want to give users the option to play from different sources.
There can only be one active MPMoviePlayerController, it won't mind if the user didn't play it yet. I do not know the technical reason, but I do know that this is the normal behavior when you do that.
My advice would be to use AVAudioPlayer to achieve what you want. The sad part if that you will have to implement the UI of the player.
Ok,
So I am trying to seamlessly loop together three sound files with the second file being looped against itself n times. Let's assume I can get them to loop seemlessly together in another program by butting them together. however when I use audioPlayerDidFinishPlaying delegate method of avaudioplayer there is a slight delay in the butting together (even with using the "prepareToPlay" method. The other bit of complexity is that the middle sound needs to continue looping n times AKA as long as the touchesDidEnd method has not been called, at which point the program would play the 3rd and final clip to end the sound "playlist."
As an example think an audience giving applause after a show. sound file A would contain the initial swell of applause, sound file 2 would contain a loopable sample of the crowd cheering at a continuous rate until the user lifts up on the button, at which time the program should kick into the 3rd sound file, which would be the applause of the crowd tailing off.
So my initial attempt using AVAudioPlayer seemed not quick enough to loop back to back without delay so I need another quicker way to do this, suggestions?
For the looping, check out the numberOfLoops property of AVAudioPlayer. Works better than trying to handle the loop logic yourself using the player's delegate.
As for fading smoothly from one looping sample to a 'tail' sample, that's going to be difficult to pull off with AVAudioPlayer. Probably your best bet is to start another player with the trailing sound file and use a timer to rapidly cross fade between the two using the volume property of each.
If that's not satisfactory (and I suspect it may not be) I don't think you'll have much choice but to drop down to the AudioQueue API to pull this off.
I have a quicktime file (.mov) generated by Keynote. When played in quicktime, it pauses itself at dozens of pre-defined points waiting for user input. It is basically a slide show with transitions pre-rendered to video.
I want to wrap this in an iPhone app, but see no methods on an MPMoviePlayerController to do anything other than play, which does not pause at the pause points.
Also, I want to be able to play backwards to a prior stop point if the user taps elsewhere on the phone.
Is there a better library for this than MPMoviePlayerController or (deprecated?) UIMoviePlayerController? Or am I overlooking methods that would allow this?
If you think about what you're trying to do, this is actually a fairly complex task. What you're really asking for is the ability to hook up an arbitrary movie playing UI tied to unique gestures, based on the specifics of your movie. I don't think either of the classes in question is going to get you there.
The easiest solution here might be content-based: generate one quicktime movie per "group" of Keynote slides, where each group ends at a pause point, and then it should be pretty easy to interpret gestures to either advance to the next movie (or load it automatically when you reach the end of the last one), or return to the start of the currently playing movie.