How to record sound of a key press on iphone? - iphone

I am developing an application in which I want to record the sound of a piano key press. I'm not able to find anything relevant on the internet which helps.
Can anybody share the code or any link which shows how to record the data of the piano key press, store it somewhere in memory and then play it again?
or
If anybody knows how to get the key press event of the keyboard and record it, that would also be appreciated.
Thanks,
Mishal

It sounds like your particular need does not involve MIDI or capturing notes from a digital piano, if I am reading correctly. You want just the audio sound of a piano, to play back on an iPhone app?
A few questions/thoughts:
First, do you just need one note/sound? If so you should be able to easily find a sound file that is to your liking on a site that sells sound samples. I myself use sounddogs.com for various odd projects.
Next, what sort of code do you need to play the sound? What programming language are you developing the app in and how do you trigger the sound playback? These details will be helpful in giving you some ideas.
Finally, if the main obstacle is just finding and recording the sound, this question may be better moved to superuser.com since that site deals more with general computer questions, media, and technology. (StackOverflow is focused strictly on programming.)

Related

Is it possible to purchase a song on iTunes in app to be recorded over?

I'm a new developer working on an app that allows users to record vocals over a track. I have some tracks that I am selling on iTunes and I would like for users to be able to purchase the a tracks from inside the app and load them to be recorded over.
So what I want is for a user to select a track listing from a table, purchase the track in-app, and be able to press button that will switch views to an audio recorder that loads that track to be recorded over. I've been scouring the documentation and I'm struggling to figure out whether this is even possible.
Does anyone know if this is possible, and can anyone point me in the right direction as to where to begin piecing the code together?
Thank you!
Short answer: Yes it's possible to do what you're trying to do
Long answer: It's possible to access the audio data from any song in the music library using an AVAssetReader (more info here How would you connect an iPod library asset to an Audio Queue Service and process with an Audio Unit? and in a bunch of other SO questions)
You'll probably need to copy the song file into the app's documents directory first to work with it. Then you'll probably need to use Audio Units to mix the microphone input with the audio, but that's a whole other topic that I'm not particularly familiar with so you'll have to search SO for more info on that, there's plenty of related questions.
As for purchasing the song, the easiest way would probably be to just link to the song in the iTunes store and have them buy it there, I believe you can even be an iTunes affiliate so you can possibly make additional money on the purchases that way. Once they have the song, it will be in their library and you can use the AVAssetReader to get it.
You could have the songs listed in a table, and in the didSelectRowAtIndexPath: delegate method you could open the link to the iTunes store for that particular song.
Hope that helps.

How can I record currently playing audio on the iPhone?

I'd like to record what the iPhone is currently outputting. So I'm thinking about recording audio from Apps like Music (iPod), Skype, any Radio Streaming App, Phone, Instacast... I don't want to record my own audio or the mic input.
Is there an official way to do this? How do I do it? It seems like AVAudioRecorder does not allow this, can somebody confirm?
Officially you can't. The audio stream belongs to the app playing it ,and iOS.
The Sandbox paradigm means that a resource owned by your App can't be used by another App. Resource here means Audio/Video stream or file. Exceptions are when a mediator like Document interaction controller are used.
If you want to do this you'd have to start with deducing AVFoundation's private methods and find out if theres a way there. Needless to say this it wouldn't be saleable on the App store and will probably only be possible on a jailbreak.
Good Luck.
TLDR;
This is only feasible only from time to time, as it's a time expensive process.
You can record the screen while listening your songs on Spotify, Music or whatever music application.
This will generate a video on your Photos application. That video can be converted on MP3 from your computer.
Actually, this is not true. The screen recordings will not actually have the audio from Apple Music at all, as it blocks it. Discord also uses this pipe as well, so you cannot record Discord audio either this way.

How to record game in cocos2d iPhone

I am developing a cocos2d app.
It's almost completed but now I want to record the activities of my app as a video file, including sound produced by the app.
How can I implement this?
Anybody can help me.
Please suggest a way to implement this.
Thanks in advance.
The question isn't new, but since it isn't answered I thought I'd pitch in:
We provide an SDK called "Everyplay" that allows you to do exactly what you're looking for. It's free to use, and is lightweight.
We provide out-of-the-box integrations for Unity3D, cocos2d (1.x, 2.x), cocos2d-x, and you can of course integrate to a custom OpenGL-based game engine.
The documentation is available at https://developers.everyplay.com/doc
The documentation contains an example app key to use when developing, but you can of course sign up for your own client key at https://developers.everyplay.com/
There are many options - and the fact that your app is cocos2d doesn't matter much.
iSimulate works well. You can actually play the app on your device and record the gameplay as well as the touch events. This is important if you want to show user interaction in your app. You run the app in the simulator but you control it from your device.
If you just want to record the app interaction without caring about showing users the touch events, you can use Screenflow or Jing or some other recording software. I used to use Jing (free) but Screenflow works better for me and it also lets you create more advanced video like a trailer with effects. edit You should be able to capture touch events through the simulator with Screenflow too. You can choose to show them or not. And can use different indicators for those events.
Search on google for mac or iphone recording software. There are many options. I had the best experience with Screenflow because I wanted to make a trailer and gameplay video.
I'm developing similar application which allow user record the activity within cocos2d-x activity.
I'm using screen capture method and then combine it using FFMPEG. The performance wasn't too good thought but is the easiest way to achieve.

Recording sounds created within an iPhone app

I'm new to programming in Objective-c and the iPhone but I am working on an app to teach myself. I have been trying to figure out how to record sounds on the iPhone. Apple provides excellent documentation for recording from the microphone with AVAudioRecorder but I want to record sounds made by my app, or even just record sounds when buttons are pressed (button is pressed, certain audio gets recorded).
I have no clue how to do this and can't seem to find anything that would help me along this path, only microphone stuff.
Can anyone share ideas or code that would make this possible?
Thanks
Once you move beyond the convenience classes like AVAudioRecorder, you've got a lot of studying to do.
I would start with:
Getting Started with Audio and Video
Multimedia Programming Guide:Audio
Core Audio Overview
Audio programming is a very large and complex subject. If you want to customize, be prepared to spend some time learning it.
I've made a sample app that records sounds/audio and has a playback. Hope this helps! https://github.com/casspangell/AudioMic

Is it possible to both play a sound and record from the microphone at the same time on the iPhone?

I want to both play sound and record sound at the same time on the iPhone.
All the apps which record sound first disable any music playing. However as music would disrupt their purpose I don't know if they're doing this deliberately or whether the iPhone does it automatically when you record from the microphone.
Does anyone have experience with this?
Refer to this page. Good luck!
I've heard something about this on one episode of the mobile orchard podcast - the one with Michael Tyson, the creator of Loopy. During the discussion, Michael explained that he had to include some code to filter out the sounds that were coming in through the microphone in realtime as other sounds were being played on the speaker.
Based on that discussion, it seems entirely possible to both play and record at the same time, but I'm sure you'll have to do your own filtering to avoid recording the sounds your playing.
You can use either a core audio unit or an audio queue, and
you need to make sure that your audio session category is set to kAudioSessionCategory_PlayAndRecord.
Beware that sound output when you use this session is much quieter
than the normal solo session (observed on 3.0).