This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Accelerate | |
import AVFoundation | |
func reverse(fromUrl: URL) -> URL? { | |
do { | |
let input = try AVAudioFile(forReading: fromUrl) | |
let format = input.processingFormat | |
let frameCount = AVAudioFrameCount(input.length) | |
let outSettings = [AVNumberOfChannelsKey: format.channelCount, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIFont { | |
static func monospacedFont(at size: CGFloat) -> UIFont{ | |
let bodyFontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: UIFont.TextStyle.body) | |
let bodyMonospacedNumbersFontDescriptor = bodyFontDescriptor.addingAttributes( | |
[ | |
UIFontDescriptor.AttributeName.featureSettings: [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Client.swift | |
// MultiConnect | |
// | |
// Created by michal on 29/11/2020. | |
// | |
import Foundation | |
import Network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AVFoundation | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
class AudioPlayer { | |
var topAudioFiles: [AVAudioFile] = [] | |
var engine:AVAudioEngine | |
var backgroundAudioNode: AVAudioPlayerNode | |
var backgroundAudioFile: AVAudioFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stream facetime camera (0) | |
ffmpeg -f avfoundation -framerate 30 -i "0" -video_size 1024x720 -vcodec libx264 -preset ultrafast -f flv "rtmp://127.0.0.1/live" | |
# framerate needs to be set before the "-i" (input) | |
# list available devices: | |
ffmpeg -f avfoundation -list_devices true -i "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AVFoundation | |
import UIKit | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
class AudioPlayer { | |
var backgroundAudioFile:AVAudioFile | |
var topAudioFiles: [AVAudioFile] = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// ObjC | |
@implementation NSUserDefaults(Tracking) | |
+ (void)load { | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
Class class = [self class]; | |
SEL originalSelector = @selector(setObject:forKey:); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func connectAudioUnitWithPlayer() { | |
var componentDescription = AudioComponentDescription() | |
componentDescription.componentType = kAudioUnitType_Effect | |
// used https://codebeautify.org/string-hex-converter to convert strings to fourCC hex | |
componentDescription.componentSubType = 0x44656d6f // "Demo" | |
componentDescription.componentManufacturer = 0x44656d6f // "Demo" | |
componentDescription.componentFlags = 0 | |
componentDescription.componentFlagsMask = 0 | |
AUAudioUnit.registerSubclass(VolumePluginAudioUnit.self, as: componentDescription, name: "demo: VolumePlugin", version: UInt32.max) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@IBDesignable | |
class CustomView: UIView { | |
@IBOutlet var contentView: UIView! | |
@IBOutlet weak var collectionView: UICollectionView! | |
override init(frame: CGRect) { | |
super.init(frame: frame) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.swift | |
// MJPEGreader | |
// | |
// Created by michal on 17/11/2017. | |
// Copyright © 2018 michal. All rights reserved. | |
// | |
import Foundation |
NewerOlder