Skip to content

Instantly share code, notes, and snippets.

#define _GNU_SOURCE
#include<stdio.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
・MIDIデータを含むバイナリファイルからSMFファイルを出力する フォーマットは道なのでこれから解析していく
・フォルダ内にある拡張子tmpのファイルが解析対象になる このファイルは先頭部分に一定サイズのヘッダがあり、続いてMIDIイベントタイムスタンプまたはデルタタイムを含むインデックスエリア、そのあとにタイムスタンプの無いMIDIイベントの羅列が含まれる タイムスタンプデータをもとに、適切な数のMIDIイベントを拾い上げて、タイムスタンプ付きのMIDIデータに再構成する必要がある
・仮の構造として、0x78バイトまでは未解析のヘッダとして取り扱う タイムスタンプブロックが始まり、「8バイトのイベントサイズ構造体(先頭4バイトは未解析のビッグエンディアンのDWORD値、2バイトでイベントのバイトサイズ、2バイトは未定義)、続いて8バイトのタイムコード(先頭2バイトは未解析、2バイトのイベントコードA、2バイトのデルタタイム、2バイトのイベントコードB)」の16バイトセットが続く イベントコードBが0003になったところでタイムスタンプは終わる
・TImestamp blockのlogのINFOで、何バイト目を処理中なのかを表示して また、仮に10ブロック読んだところでいったん強制終了して
イベントサイズ2バイト、他のもBigEndian
・0003のコード取得後、4バイトの未解析データをスキップすると、0xF0が見えるはず ここをMIDIデータの先頭とし、各タイムスタンプブロックに​記述されたイベントサイズのバイト数を割り当てていく
・10ブロックリミットを解除して動作が正しいか確認する
・タイムスタンプブロックに割り当てられたMIDIイベントをログに出して
・ログが長くなってしまったので、タイムスタンプに割り当てられたMIDIイベントを表示する際には最初の10ブロックだけに限定して
・ブロック数制限を外して、代わりにログをファイルに出力してみるにはどうすればいい
# MIDIデータからSMFファイルを出力する
_Exported on 8/11/2025 at 01:33:55 GMT+9 from Cursor (1.3.9)_
---
**User**
MIDIデータを含むバイナリファイルからSMFファイルを出力する フォーマットは道なのでこれから解析していく
---
Booting...
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@
@ chip__no chip__id mfr___id dev___id cap___id size_sft dev_size chipSize
@ 0000000h 0c22017h 00000c2h 0000020h 0000017h 0000000h 0000017h 0800000h
#include <MIDI.h>
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI); // MIDI IN/OUT on Serial1
void setup() {
Serial.begin(115200);
MIDI.begin(MIDI_CHANNEL_OMNI);
MIDI.setHandleSystemExclusive(onSysEx);
sendGSReset();
delay(1000); // 安定待ち
sendIdentityRequest(); // 送信
package jp.co.signal.pics.service;
import java.util.List;
import jp.co.signal.pics.model.Intersection;
import jp.co.signal.pics.model.PedestrianSignal;
/* loaded from: classes.dex */
public interface PICSService {
/* loaded from: classes.dex */
喙cpu>: [tmon] Probing for device adt7461
<cpu>: Loading stage 2 primary bootloader...
<cpu>: Stage2 loaded
<cpu>:
<cpu>: Memory is being checked.
<cpu>: Memory Check( 00000000 ) : OK.
<cpu>: Memory Check( 55555555 ) : OK.
<cpu>: Memory Check( aaaaaaaa ) : OK.
<cpu>: Memory Check( ffffffff ) : OK.
<cpu>:
===================================================================
MT7621 stage1 code Mar 12 2015 14:43:30 (ASIC)
CPU=500000000 HZ BUS=166666666 HZ
==================================================================
Change MPLL source from XTAL to CR...
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x412fd050]
[ 0.000000] Linux version 5.15.123-yocto-standard (oe-user@oe-host) (aarch64-poky-linux-gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.38.20220313) #1 SMP PREEMPT Mon Jan 29 02:33:21 UTC 2024
[ 0.000000] Machine model: sun55iw3
[ 0.000000] OF: reserved mem: 0x0000000000020000..0x000000000002ffff (64 KiB) nomap non-reusable mcu0iram@20000
[ 0.000000] OF: reserved mem: 0x0000000000030000..0x0000000000037fff (32 KiB) nomap non-reusable mcu0dram0@30000
[ 0.000000] OF: reserved mem: 0x0000000000038000..0x000000000003ffff (32 KiB) nomap non-reusable mcu0dram1@38000
[ 0.000000] OF: reserved mem: 0x0000000007280000..0x00000000072bffff (256 KiB) nomap non-reusable riscvsram0@7280000
[ 0.000000] OF: reserved mem: 0x00000000072c0000..0x00000000072fffff (256 KiB) nomap non-reusable riscvsram1@72c0000
[ 0.000000] OF: reserved mem: 0x0000000048000000..0x0000000048ffffff (16384 KiB) map non-reusable bl31
[ 0.000000] OF: reserved mem
#include <93C46.h>
#define pCS 2
#define pSK 13
#define pDI 10
#define pDO 11
#define SPKEN 9
// Prints all words of the buffer
void debugPrint(word* buff, int len) {
Serial.print("\n\t00\t01\t02\t03\t04\t05\t06\t07\t08\t09\t0A\t0B\t0C\t0D\t0E\t0F");