Skip to content

Instantly share code, notes, and snippets.

import Foundation
import Combine
import SwiftUI
/// An `ObservableObject` ViewModel that subscribes to a `CDJ3000Manager`
/// and publishes its state for a SwiftUI View.
///
/// This class is marked with `@MainActor`, which ensures that all UI-related
/// state updates are automatically published on the main thread.
@MainActor
import Foundation
/// A `Sendable` struct for defining a single MIDI Note message.
public struct MidiNoteMapping: Sendable, Equatable {
public var channel: UInt8
public var note: UInt8
}
/// A `Sendable` struct for defining a single MIDI Control Change (CC) message.
public struct MidiControlChangeMapping: Sendable, Equatable {
import Foundation
import CoreMIDI
// Note: This file assumes the `MIDIAdapter.h` and `MIDIAdapter.mm` files
// from your project are available and included in the build target.
// It also assumes Core MIDI definitions like MIDIMessage_32 are available.
// --- UPDATE: We are removing the MIDIAdapter dependency for this class ---
// Define a simple Deck ID for clarity
public enum DeckID: Sendable {
@voxels
voxels / CDJ3000_MIDI.swift
Last active November 14, 2025 14:01
CDJ 3000 midi manager actor
import Foundation
import CoreMIDI
import Combine
// MARK: - MIDI Command Mapping
/// A namespace for mapping CDJ-3000 MIDI commands from the official PDF.
/// We focus on MIDI 1.0 Channel Voice messages (Note On/Off, Control Change).
/// "n" (e.g., 9n, Bn) corresponds to the MIDI channel (0-15).
private enum CDJ3000Commands {
@voxels
voxels / VideoConverter.swift
Last active February 22, 2024 10:58
Video Converter to Spatial
//
// VideoConverter.swift
// SpatialVideoConverter
//
// Created by Michael A Edgcumbe on 2/21/24.
//
import Foundation
import AVFoundation
import VideoToolbox
@voxels
voxels / PlaceSearchSession
Created March 19, 2023 15:35
CloudKit fetching of API Keys
//
// PlacesSearchSession.swift
// No Maps
//
// Created by Michael A Edgcumbe on 3/19/23.
//
import Foundation
import CloudKit
@voxels
voxels / priceless_lost_and_found.md
Last active July 12, 2019 23:43
Priceless Lost and Found
@voxels
voxels / LaunchController.swift
Created August 14, 2018 17:11
LaunchController
//
// LaunchController.swift
// ToyPhotoGallery
//
// Created by Voxels on 7/2/18.
// Copyright © 2018 Michael Edgcumbe. All rights reserved.
//
import UIKit
@voxels
voxels / scrollViewDidScroll.swift
Last active August 2, 2018 20:09
Transforming a UICollectionViewCell during scrollViewDidScroll with a CGAffineTransform
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollDirection == .horizontal {
calculateTransforms(with:scrollView.contentOffset)
}
}
func calculateTransforms(with offset:CGPoint) {
guard let collectionView = collectionView else {
return
}
@voxels
voxels / GalleryViewController_excerpt.swift
Last active August 2, 2018 17:59
An example of animateCollectionViews, a method to swap out two collection views located in the same container
// MARK: - Animation
extension GalleryViewController {
func animateCollectionViews(preview:Bool, with indexPath:IndexPath?) {
guard let oldCollectionView = collectionView, let collectionViewModel = oldCollectionView.model else {
return
}
let angle = CGFloat(Measurement(value: 90, unit: UnitAngle.degrees)
.converted(to: .radians).value)