$ swift main.swift
Default output device: MacBook Pro Speakers
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 Foundation | |
extension String { | |
func trimPrefix(_ prefix: String) -> String { | |
guard self.hasPrefix(prefix) else { | |
return self | |
} | |
return String(self.dropFirst(prefix.count)) | |
} |
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 Foundation | |
import Darwin | |
class A: NSObject { | |
var task = Process() | |
var slaveFile: FileHandle? | |
var masterFile: FileHandle? | |
override init() { |
This script reads /tmp/input.wav
and writes the copy of input as /tmp/output.wav
.
$ swift main.swift
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 | |
func readWavFile(_ path: String) -> [[Int16]]? { | |
guard let url = URL(string: path) else { | |
return nil | |
} | |
guard let audio = try? AVAudioFile(forReading: url, commonFormat: .pcmFormatInt16, interleaved: false) else { | |
return nil | |
} | |
guard let buffer = AVAudioPCMBuffer(pcmFormat: audio.processingFormat, frameCapacity: AVAudioFrameCount(audio.length)) else { |
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 Foundation | |
struct Complex64 { | |
var real: Float | |
var imag: Float | |
init(_ r: Float, _ i: Float) { | |
self.real = r | |
self.imag = i | |
} |
NewerOlder