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 | |
/* | |
Generate the I and Q components for a local oscillator | |
*/ | |
public class IQ_Oscillator { | |
let tau = 2 * Double.pi | |
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 | |
/* | |
Demo implementation of the famous Goertzel algorithm in Swift | |
NB it is not currently possible to make this generic without | |
also pulling in the Swift Numerics package. | |
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
// couple of useful functions for dealing with an AVCaptureSession | |
// chucked out there for posterity and search | |
// What led to me to do this : Set size of AVCaptureAudioDataOutput buffer | |
// What might also lead you here : Swift AudioValueTranslation | |
// PLEASE NOTE : There are no error checks in this code, demo purposes only. | |
import AVFoundation |
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 CoreAudio | |
import OSLog | |
/* | |
So you want to get a list of audio input and output devices on macOS do you? | |
Should be easy right? |
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
func reverse <T: FixedWidthInteger> ( word: T ) -> T { | |
var word = word | |
var rev : T = 0 | |
for _ in (0..<word.bitWidth) { | |
rev = (rev << 1) + (word & 0b1) | |
word >>= 1 | |
} | |
return rev |
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 | |
// so the main limitation of the previous efforts was that we couldn't do e.g. | |
// p { "here is " em { "some" } "emphasis" } | |
// without starting to write crazy amounts of buildBlock functions, so... | |
extension XMLNode { | |
func named(_ name: String) -> XMLNode { |
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 XMLNode { | |
func named(_ name: String) -> XMLNode { | |
self.name = name | |
return self | |
} |
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 | |
@_functionBuilder struct XMLBuilder { | |
static func buildBlock(_ content: String) -> String { | |
return content | |
} |
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 PeekAheadIterator<T> { | |
let elements:[T] | |
public init(elements:[T]) { | |
self.elements = elements | |
} |
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 | |
import AVFoundation | |
class ViewController: UIViewController, AVSpeechSynthesizerDelegate { | |
let synth = AVSpeechSynthesizer() | |
let avsesh = AVAudioSession.sharedInstance() | |
let voice = AVSpeechSynthesisVoice(language: "en-GB") | |
let avopts:AVAudioSessionCategoryOptions = [ | |
.MixWithOthers, | |
.DuckOthers, |
NewerOlder