Skip to content

Instantly share code, notes, and snippets.

View povik's full-sized avatar

Martin Povišer povik

View GitHub Profile
@povik
povik / newttcam.py
Created June 21, 2020 12:07
Modified vispy's turntable camera
# -*- coding: utf-8 -*-
# Copyright (c) Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
from __future__ import division
import math
import numpy as np
from vispy.scene.cameras.base_camera import BaseCamera
@povik
povik / speaker_amp.py
Last active September 21, 2021 20:21
Play audio through the embedded speaker on Mac mini
# speaker_amp.py -- play audio through the embedded speaker on Mac mini
#
# tested with m1n1 64dab9482
#
# sample usage with sox:
#
# sox INPUT_FILE -t raw -r 48000 -c 1 -e signed-int -b 32 -L - gain -63 | python3 ./speaker_amp.py
#
# (expects mono, 24-bit signed samples padded to 32 bits on the msb side)

Sound Driver Changelog for asahi 6.0-rc1 Merge

2021-08-20

Since the sound drivers will have a couple of changes I am writing this note for the people of #asahi.

The ALSA card now has devices Primary/hw:0,0 and Secondary/hw:0,1. Routing of audio from the devices to speakers/headphones depends on the state of the card's controls (those seen in alsamixer). By default both headphones/speakers are routed to the primary device, with one or the other being enabled based on the plug state of the jack connector. You can override that. To drive all the speakers on large (>2ch) speaker arrays, you need to use the secondary device. So you set the Speaker Playback Mux to Secondary, then stream audio to hw:0,1. This is because the primary device has some parameters set to appease the jack codec -- this limitation may be lifted in the future.

Anyway, such details should be hidden in proper userspace configuration, which we have yet to write.

@povik
povik / example_plugin.py
Last active December 7, 2023 15:58
Example plugin (to demonstrate Python binding at YUG 4)
#!/usr/bin/python3
import libyosys as ys
class VisitallPass(ys.Pass):
def __init__(self):
super().__init__("visitall", "visit all selected cells across all modules")
def py_help(self):
ys.log("Hello YUG! TODO: write an actual help message...\n")
# opcode constants
const LUI = 0x0d << 2 | 3;
const AUIPC = 0x05 << 2 | 3;
const JAL = 0x1b << 2 | 3;
const JALR = 0x19 << 2 | 3;
const BRANCH = 0x18 << 2 | 3;
const LOAD = 0x00 << 2 | 3;
const STORE = 0x08 << 2 | 3;
const OP_IMM = 0x04 << 2 | 3;
const OP = 0x0c << 2 | 3;
@povik
povik / foldrv32-branchfork.fold
Last active January 1, 2024 14:28
foldrv32-branchfork.fold
# opcode constants
const LUI = 0x0d << 2 | 3;
const AUIPC = 0x05 << 2 | 3;
const JAL = 0x1b << 2 | 3;
const JALR = 0x19 << 2 | 3;
const BRANCH = 0x18 << 2 | 3;
const LOAD = 0x00 << 2 | 3;
const STORE = 0x08 << 2 | 3;
const OP_IMM = 0x04 << 2 | 3;
const OP = 0x0c << 2 | 3;