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

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
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
[45, 45, 52, 52, 54, 54, 52, 50, 50, 49, 49, 47, 47, 45, 52, 52, 50, 50, 49, 49, 47, 52, 52, 50, 50, 49, 49, 47, 45, 45, 52, 52, 54, 54, 52, 50, 50, 49, 49, 47, 47, 45]
这是一首《小星星》的谱子音高表 🤔