Skip to content

Instantly share code, notes, and snippets.

@olenhad
olenhad / AVAudioPCMBuffer+Additions.m
Last active January 2, 2021 02:49
Combining AVAudioPCMBuffers. Assumes non interleaved format
@implementation AVAudioPCMBuffer (LiveAdditions)
- (AVAudioPCMBuffer *)combineWithBuffer:(AVAudioPCMBuffer *)buffer {
if (![buffer.format isEqual:self.format]) {
return nil;
}
AVAudioPCMBuffer *combined = [[AVAudioPCMBuffer alloc] initWithPCMFormat:self.format frameCapacity:self.frameCapacity + buffer.frameCapacity];
combined.frameLength = self.frameLength + buffer.frameLength;
@olenhad
olenhad / infinite_cmd.py
Created April 1, 2020 08:20
Running a command infinitely until it succeeds
import subprocess
import sys
def run_command(command):
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
output = process.stdout.read(1).decode()
if output == '' and process.poll() is not None:
break
if output != '':