Skip to content

Instantly share code, notes, and snippets.

View davipatury's full-sized avatar

Davi Patury davipatury

  • Brasília, DF, Brazil
  • 01:43 (UTC -03:00)
View GitHub Profile
@davipatury
davipatury / midi.asm
Created October 19, 2020 20:30
Non-blocking RISC-V Syscall MIDI
###############################################
# Programa de exemplo para Syscall MIDI #
# Implementação assíncrona (non-blocking) #
# ISC Oct 2020 #
# Davi Jesus de Almeida Paturi #
###############################################
.data
LAST_DURATION: .word 0 # duracao da ultima nota
LAST_PLAYED: .word 0 # quando a ultima nota foi tocada
@davipatury
davipatury / parseNotes.js
Last active February 6, 2025 19:14
HookTheory to RISC-V midi
(async () => {
const noteTable = {
'1': 72,
'#1': 73,
'1s': 73,
'1f': 73,
'b1': 73,
'b2': 73,
'2': 74,
'#2': 75,
/*
* Compara dois naipes:
* se o naipeA for maior que o naipeB, irá retornar um valor positivo
* se o naipeA for menor que o naipeB, irá retornar um valor negativo
* se o naipeA for igual ao naipeB, irá retornar 0
*/
const compararNaipe = (naipeA, naipeB) => {
const ordemNaipes = [ '♣', '♦', '♥', '♠' ]
return ordemNaipes.indexOf(naipeA) - ordemNaipes.indexOf(naipeB)
}