duangsuse::Echo
719 subscribers
4.28K photos
130 videos
583 files
6.49K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
duangsuse::Echo
为实现扒谱程序做了一点搜集 https://github.com/nwhitehead/pyfluidsynth 可以作为音阶合成库 https://github.com/vishnubob/python-midi 可以作为 MIDI 库 https://pypi.org/project/pyreadline/ 可以作为 CLI 监听库 MIDI 这个比较灵性,它不像 subtitle 那么简单,一个 MID 文件是由 events 构成的,如 NoteOn(tick,veloc,pitch), NoteOff(tick…
……其实设计到现在我觉得还是蛮有出入的,毕竟我一不熟悉 MIDI 二不熟悉 GUI 一堆不止是按步骤依赖去 make 而不考虑 events, threading 的东西

主要还是开始录音高的时候,原因居然是因为我觉得那样显得高级不少:

def onAppend():
if n in range(0, 9+1):
code.append(str(n))
pitches.append(n)
print(n, end="")
else:
code.append(f"[{n}]")
pitches.pop()
print(f"[{n}]", end="")
def onDelete():
if code[-1] == ']':
code = code.lstrip(string.digits)[:-1]#'['
reprint(code)
else: removeNChar(1)


这个原因很智障,而且莫名其妙,是不是 😂
我居然还在考虑那个 code 可以在某种程度上自动和终端上的更新…… 只要我做好类似 update_line(new_code, code, mode="len_subtract") 这种,然后就可以 dropWhileRight 什么的…… 真是蠢

后来我发现…… 其实是我想多了,因为音高的确认往往是(没错,劳资就是不懂乐理、劳资就是只知道音高数字)需要很多次测试才能完成的,所以按下 Enter 键来确认而不是不断删除,反而是一个合理的做法……

说句题外话, fluidsynth 的 start() 方法也修好了,所以不必用 pyaudio 了,emmm

srt.compose(srt.Subtitle(i, v.start, v.end, v.content) for i, v in enumerate(srts)) 🤔 把 index 信息混进去好像也不太难
hachiko.zip
18.3 KB
#Python #code 准备赶快继续重构下了… 发现很多东西有出入,可以简单化也适合我这种非资深又爱偷懒的……
def abrange(start, stop, step_a, step_b):
acc = start; is_a = True
while acc < stop:
yield acc
acc += step_a if is_a else step_b
is_a = not is_a

#Python #code 写了正则解析程序,又灭掉一些不好的代码……
import re
pat_cdecl = re.compile(r"(\w+)\s+(\w+)\((((\w+)\s+(\w+))(,\s*(\w+)\s+(\w+))*)?\);")

ctype = {
"void*": c_void, "char*": c_char_p,
"int": c_int, "double": c_double
}.__getitem__
def foreign(cdecl):
"""t_result name(type name, ...args);"""
m = pat_cdecl.match(cdecl).groups()
t_result, name = m[0:2]
if m[3] == None: return cfunc(name, ctype(t_result))
args = [(m[i+2], ctype(m[i+1])) for i in range(3, len(m), 3)]
return cfunc(name, ctype(t_result), *args)

#Python #code 停,不用 regex 了,我们用 pyparsing!
注: pyparsing 是老项目了,设计表现力和 ParserKt 有点像 https://github.com/pyparsing/pyparsing/blob/master/examples/jsonParser.py
草,这个 emmm
This media is not supported in your browser
VIEW IN TELEGRAM
^.* = foreign\("(.*)"\)$ 太过生草
从纯手动定义C FFI、到利用头定义动态构造对象、到动态生成Python代码…… 🤔
Forwarded from 依云
GObject?
Forwarded from 依云
它可以在支持的语言里消除前缀、使用 obj.method 的表示法
Forwarded from 依云
那不如用 cffi
Forwarded from dnaugsuz
那个东西好用吗,体积上和安装量应该没问题吧 🤔
Forwarded from 依云
好用啊。但是并不能消除前缀。
Forwarded from 依云
它可以解析 C 声明,然后你就可以直接用了。也可以生成二进制绑定
duangsuse::Echo
Photo
Hachi 已经基本写完了,我打算扒个谱子测试下
t0 = time()
t1 = None
def giveSegment():
nonlocal t1
t2 = time()
reducer.accept( (t1-t0, t2-t0, synth.last_pitch) )
t1 = t2 #< new start

synth.last_pitch = next(pitchz, 50)
def nextPitch():
try: return next(pitchz)
except StopIteration: raise NonlocalReturn("done")
def doSplit(): synth.noteSwitch(nextPitch())

def onEvent(event):
nonlocal t1
if event.type == pygame.KEYDOWN:
key = chr(event.key)
if key == 'a':
t1 = time()
synth.noteon(synth.last_pitch)
elif event.type == pygame.KEYUP:
key = chr(event.key)
if key == 'a':
synth.noteoff()
synth.last_pitch = nextPitch()
giveSegment()
elif key == 's' and not is_hot: doSplit(); giveSegment()
elif key == ' ': onPausePlay()
基本上主要逻辑就这些
……出 bug, 修复了 ,果然简单才是真理啊! 根本不该有什么 init update 顺序的问题,emmm