- UID
- 3
- 积分
- 8169
- 帖子
- 259
- 主题
- 68
- 论坛币
- 5016
- 威望
- 54
- EP值
- 2533
- MP值
- 20
- 阅读权限
- 200
- 注册时间
- 2011-8-3
- 在线时间
- 1097 小时
- 最后登录
- 2022-10-8
|
預覽:http://pan.baidu.com/s/1hqqY9CC#dir/path=%2FSaiyakuFX_Preview- from tcaxPy import *
- from util.tcAudio import *
- def tcaxPy_Init():
- # some common pre-defined global values
- global fontSize # as name implies
- global resX # horizontal resolution
- global resY # vertical resolution
- global marginX # horizontal margin
- global marginY # vertical margin
- global spacing # space between texts
- global frameDur # milliseconds per frame
- global lineNum # number of lines
- global textNum # textNum[i], number of texts in ith line
- global _BT # _BT[i], start time of a line
- global _ET # _ET[i], end time of a line
- global _KT # _KT[i][j], karaoke time of a syllable
- global _SK # _SK[i][j], elapsed karaoke time before reaching a certain syllable
- global _TXT # _TXT[i][j], as name implies
- global _L # _L[i], total width of a line
- global _W # _W[i][j], width of a text
- global _H # _H[i][j], height of a text
- global _A # _A[i][j], advance of a text, usually larger than width
- global _AD # _AD[i][j], distance between the current text to the first text of the line
- fontSize = GetVal(val_FontSize)
- resX = GetVal(val_ResolutionX)
- resY = GetVal(val_ResolutionY)
- marginX = GetVal(val_OffsetX)
- marginY = GetVal(val_OffsetY)
- spacing = GetVal(val_Spacing)
- frameDur = 1000 / GetVal(val_FXFPS)
- lineNum = GetVal(val_nLines)
- textNum = GetVal(val_nTexts)
- _BT = GetVal(val_BegTime)
- _ET = GetVal(val_EndTime)
- _KT = GetVal(val_KarTime)
- _SK = GetVal(val_KarTimeDiff)
- _TXT = GetVal(val_Text)
- _L = GetVal(val_TextLength)
- _W = GetVal(val_TextWidth)
- _H = GetVal(val_TextHeight)
- _A = GetVal(val_TextAdvance)
- _AD = GetVal(val_TextAdvanceDiff)
- def randi():
- if randint(0,1)==0:
- return -1
- else:
- return 1
- def med(fft):
- X = 0
- for i in range(100,200):
- X += fft[i]
- return X/100
- def beat(F):
- global BEAT
- BEAT = []
- BEAT.append(255)
- for a in range(len(F)-1):
- if int(abs(F[a+1] - F[a])*100000)> 240:
- BEAT.append(3.5)
- elif int(abs(F[a+1] - F[a])*100000)< 180 :
- BEAT.append(1)
- else:
- BEAT.append(0.5+((255-abs(F[a+1] - F[a])*100000)/255)*5)
- return BEAT
- def tcaxPy_User():
- file_name = GetVal(val_OutFile) + '.ass'
- ass_header = GetVal(val_AssHeader)
- ASS_FILE = CreateAssFile(file_name, ass_header)
- tcAudioInit()
- channel = tcAudioOpen('test.mp3')
- freq = tcAudioGetFreq(channel) # usually 44100 Hz
- duration = tcAudioGetDuration(channel)
- num = int(duration * freq / 2048)
- global F
- F = []
- for k in range(num):
- fft = tcAudioGetFFT(channel, 2048)
- F.append(med(fft))
- B = beat(F)
- CLR1 = color1("FFFFFF")+color3("000000") + alpha1(0)
- CLR2 = color1("000000")+color3("000000") + alpha1(30)
- for i in range(lineNum):
- initPosX = (resX - _L[i]) / 2 + marginX # if marginX = 0, then it's just on the middle
- initPosY = marginY
- for j in range(textNum[i]):
- ASS_BUF = []
- if _TXT[i][j] == '' or _TXT[i][j] == ' ' or _TXT[i][j] == ' ':
- continue
- posX = initPosX + _AD[i][j] + _A[i][j] / 2
- posY = initPosY + 19
- ass_main(ASS_BUF, SubL(_BT[i]+j*5, _BT[i]+_SK[i][j]-10, 10),fad(100,0)+ an(5) + pos(posX, posY) + CLR1+bord(1)+shad(0.5) ,_TXT[i][j] )
- ass_main(ASS_BUF, SubL(_BT[i]+_SK[i][j]-10, _ET[i]+j*5, 30),fad(0,100)+ an(5) + pos(posX, posY) +t(0,30,fsc(150,150)) +t(30,_KT[i][j]*10,fsc(100,100))+ CLR1+bord(1)+shad(0.5) ,_TXT[i][j] )
- for m in range(num):
- R=[(0,1),(0,-1),(1,0),(-1,0),(0,-1),(0,1),(-1,0),(1,0),(0,-1),(0,1),(randi(),randi()),(randi(),randi()),(0,1),(-1,0),(1,0),(-1,0),(1,0)]
- start = m * 100 * 2048 / freq
- end = (m + 1) * 100 * 2048 / freq
- if start > _BT[i]+j*5 and end <_ET[i]+j*5:
- ass_main(ASS_BUF, SubL(start-3, end, 20), fad(40,40)+ an(5) + pos(posX+B[m]*R[i][0], posY+B[m]*R[i][1])+blur(1.5) + CLR2, _TXT[i][j])
- WriteAssFile(ASS_FILE, ASS_BUF) # write the buffer in memory to the file
- Progress(i,j)
- tcAudioFin()
- FinAssFile(ASS_FILE)
复制代码
killmebabyED.zip
(2.35 MB, 下载次数: 3451)
|
-
1
查看全部评分
-
|