core-audio

How to programmatically create an empty .m4a file of a certain length under iOS using CoreAudio on device?

半世苍凉 提交于 2019-12-02 13:16:39
问题 I need to create a dummy .m4a file of a certain length programatically under iOS... 回答1: try this NSError *error = nil; path = [path stringByAppendingPathComponent:@"tempfile"]; NSURL *URL = [NSURL fileURLWithPath:path]; [[NSFileManager defaultManager]createFileAtPath:path contents:nil attributes:nil] NSFileHandle *writeFile = [NSFileHandle fileHandleForWritingToURL:URL error:&error]; [writeFile truncateFileAtOffset:4000000000*sizeof(Byte)]; 来源: https://stackoverflow.com/questions/7011070/how

Matt Gallagher's iOS Tone Generator

陌路散爱 提交于 2019-12-02 12:00:42
Can someone point me to a working version of Matt Gallagher's Tone Generator? http://www.cocoawithlove.com/assets/objc-era/ToneGenerator.zip As Matt says, it hasn't been updated and apparently got broken by newer APIs. I updated what I could figure out needed updating and now it compiles and runs with only deprecation warnings but all it does is make clicking sounds when the "Play" and "Stop" button are touched. I've gone through the code and looked at the documentation in Xcode for the API but it's a steep learning curve. I would love to have a working version so I could tinker with it to

AVAudioSequencer Causes Crash on Deinit/Segue: 'required condition is false: outputNode'

陌路散爱 提交于 2019-12-02 09:47:02
The below code causes a crash with the following errors whenever the object is deinitialized (e.g. when performing an unwind segue back to another ViewController): required condition is false: [AVAudioEngineGraph.mm:4474:GetDefaultMusicDevice: (outputNode)] Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: outputNode' The AVAudioSequencer is the root of the issue, because the error ceases if this is removed. How can this crash be avoided? class TestAudioClass { private var audioEngine: AVAudioEngine private var sampler:

How to write array of float values to audio file in Core Audio?

故事扮演 提交于 2019-12-02 09:20:20
问题 I am trying to implement linear convolution using Core Audio, I have the algorithm implemented and working, but I am trying to write the output of this into a .wav audio file. Here is the code for the algorithm... //Create array containing output of convolution (size of array1 + array2 - 1) float *COutput; COutput = (float *)malloc(((size1+size2)-1)* sizeof(float)); int sizeOutput = ((size1 + size2)-1); //Convolution Algorithm!!! for (i=0; i<sizeOutput; i++) { COutput[i]=0; for (j=0; j

how to read VBR audio in novacaine (as opposed to PCM)

半城伤御伤魂 提交于 2019-12-02 08:14:24
The creator of novacaine offered example code where audio data is read from a a file and fed to a ring buffer. When the file reader is created though, the output is forced to be PCM: - (id)initWithAudioFileURL:(NSURL *)urlToAudioFile samplingRate:(float)thisSamplingRate numChannels:(UInt32)thisNumChannels { ... // We're going to impose a format upon the input file // Single-channel float does the trick. _outputFormat.mSampleRate = self.samplingRate; _outputFormat.mFormatID = kAudioFormatLinearPCM; _outputFormat.mFormatFlags = kAudioFormatFlagIsFloat; _outputFormat.mBytesPerPacket = 4*self

How to write array of float values to audio file in Core Audio?

a 夏天 提交于 2019-12-02 04:00:22
I am trying to implement linear convolution using Core Audio, I have the algorithm implemented and working, but I am trying to write the output of this into a .wav audio file. Here is the code for the algorithm... //Create array containing output of convolution (size of array1 + array2 - 1) float *COutput; COutput = (float *)malloc(((size1+size2)-1)* sizeof(float)); int sizeOutput = ((size1 + size2)-1); //Convolution Algorithm!!! for (i=0; i<sizeOutput; i++) { COutput[i]=0; for (j=0; j<sizeCArray1; j++) { if (((i-j)+1) > 0) { COutput[i] += CArray1[i - j] * CArray2[j]; } } } I need to write the

When reading audio file with ExtAudioFile read, is it possible to read audio floats not consecutively?

亡梦爱人 提交于 2019-12-02 01:29:08
问题 I`m trying to draw waveform out of mp3 file. I've succeeded to extract floats using ExtAudioFileReadTest app provided in the Core Audio SDK documentation(link: http://stephan.bernsee.com/ExtAudioFileReadTest.zip), but it reads floats consecutively. The problem is, that my audio file is very long (about 1 hour), so if I read floats consecutively, it takes so much time. Is it possible to skip the audio file, then read small partial of audio, then skip and read? 回答1: Yes, use ExtAudioFileSeek()

Keep playing sound with MPMoviePlayerController and locked screen?

时光怂恿深爱的人放手 提交于 2019-12-02 01:00:08
问题 When you're watching a video with MPMoviePlayerController and the user presses the top button to lock the screen, the app goes to sleep and so does the sound from the video. Is there any way to prevent the lock from stopping the sound? If not, is there a way to intercept the lock, to create a "custom lock", to save some battery but keep playing the video? 回答1: Sounds like you haven't set your audio session category. Set the AVAudioSession 's category property to AVAudioSessionCategoryPlayback

difference between AudioQueue time and AudioQueue Device time

吃可爱长大的小学妹 提交于 2019-12-02 00:30:13
I'm trying to sync music sent from a host iPhone to a client iPhone.. the audio is read using AVAssetReader and sent via packets to the client, which in turns feeds it to a ring buffer, which in turn populates the audioqueue buffers and starts playing. I was going over the AudioQueue docs and there seems to be two different concepts of a timestamp related to the audioQueue: Audio Queue Time and Audio Queue Device Time . I'm not sure how those two are related and when one should be used rather (or in conjunction with) the other. 来源: https://stackoverflow.com/questions/12668803/difference

Controlling the volume of other applications

一曲冷凌霜 提交于 2019-12-01 22:33:30
I am trying to make an app that controls the volume of another process using the Windows 7 Audio API. What I'm looking for is the ISimpleAudioVolume for the session used by the other process. I have tried using the IAudioSessionEnumerator but it will only give me the IAudioSessionControl2 of the session. Using the IAudioSessionControl I have managed to receive notifications when I change the volume through sndvol but not change it myself. I have also tried using GetSimpleAudioVolume() from IAudioSessionManager but it will only give me sessions within the current process. How do you do it? It