Skip to content

Instantly share code, notes, and snippets.

@lijon
lijon / auv3_custom_state.m
Last active January 19, 2024 09:58
AUv3 custom state
// How to store and recall custom non-parameter based state in AUv3
- (NSDictionary*)customState { return nil; } // return your custom state here
- (void)setCustomState:(NSDictionary*)state { return; } // set your custom state here
- (void)setFullState:(NSDictionary<NSString *,id> *)fullState {
NSDictionary *custom = fullState[@"custom_data"];
if(custom) {
NSMutableDictionary *m = [fullState mutableCopy];
# (insert all the standard stuff here for esphome, wifi, api, etc...)
# https://www.az-delivery.de/en/products/d1-mini-v3
esp8266:
board: d1_mini
sensor:
- platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
name: "WiFi Signal dB"
id: wifi_signal_db
@lijon
lijon / audiosession_init.md
Created August 11, 2023 11:23
Audio Session init

setup AVAudioSession

Add NSNotificationCenter observers for AVAudioSessionRouteChangeNotification, AVAudioSessionInterruptionNotification and AVAudioSessionMediaServicesWereResetNotification

requestRecordPermission

setCategory: AVAudioSessionCategoryPlayAndRecord withOptions: AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetoothA2DP | AVAudioSessionCategoryOptionAllowAirPlay |

@lijon
lijon / ocd_sampler.py
Last active June 3, 2023 06:46
STM32 profiler using openocd
#!/usr/bin/python3
# original https://gist.github.com/ynsta/7df418cb27b908391f86, adapted for python3
# run openocd (0.9.0) with :
# $ openocd -f stlink-v2-1.cfg -f stm32f4x.cfg &> /dev/null"
# then run
# $ python2 sampler.py path_to_myelf_with_symbols
import sys
@lijon
lijon / AUM_1.4.0_news.txt
Created May 25, 2022 19:38
AUM 1.4.0 news
New in AUM 1.4.0
ENGINE
- Add 64kHz sample rate option.
- Add 'DJ style' combined LP/HP filter node.
- Make Transport Clock sample-precise when Ableton Link is disabled.
- Send reset to AUv3 when changing bypass state. Can (should) be used to clear delay lines etc.
- AUv3: don't process bypassed nodes.
@lijon
lijon / AUM_AUv3_init_order.md
Last active June 28, 2022 23:30
AUM AUv3 init order

When an AUv3 plugin is loaded from a session in AUM, this is the order of things that happens:

  • If there already was a session loaded, it's saved to a hidden file (for Restore Last State).
  • Wait for above state save to finish.
  • The new AUM session is read from file, loading session title, notes, etc.
  • Reads and sets session properties like sample rate, minimumLatency, metronome, and state for all HW and Mix busses.
  • Empty channel objects are created for all channels in the session.
  • Wait for this to finish.
  • Loads the nodes for all channels:
  • Create the node object.
// if AudioComponentCopyIcon() returns nil, call this method and try again!
- (void)componentIconHack {
AudioComponentDescription searchDesc = { 0,};
AudioComponent comp = NULL;
while(true) {
comp = AudioComponentFindNext(comp, &searchDesc);
if(!comp)
break;
UIImage *img;
@lijon
lijon / LM13700.MOD
Created July 31, 2020 09:15
LM13700 model for ngspice including LM13700_CHIP subcircuit for dual unit
*//////////////////////////////////////////////////////////////////////
* (C) National Semiconductor, Inc.
* Models developed and under copyright by:
* National Semiconductor, Inc.
*/////////////////////////////////////////////////////////////////////
* Legal Notice: This material is intended for free software support.
* The file may be copied, and distributed; however, reselling the
* material is illegal
@lijon
lijon / CALayer+persist.m
Created September 28, 2015 07:38
Pause and save animations when app going into background, resume when going foreground.
@implementation CALayer (persist)
- (NSArray*)pauseAndSaveAnimations {
NSMutableArray *array = [NSMutableArray new];
__unsafe_unretained __block void (^recurse2)(CALayer *);
void (^recurse)(CALayer *) = ^(CALayer *layer) {
for(NSString *key in layer.animationKeys) {
NSArray *a = @[layer,key,[[layer animationForKey:key] copy]];
[array addObject:a];