搜索

iVocaloid论坛

查看: 1986|回复: 0
打印 上一主题 下一主题

【Rocaloid经验总述】【三】关于RDL, CVS和CVSCommon [复制链接]

Sleepwalking

我不是技术宅!

Lv.5-章鱼须

Rank: 5Rank: 5Rank: 5

0
9
0


UID: 111156
权限: 40
属性: 宇宙人
发帖: 201 (1精)
积分: 540
章鱼: 3
大葱: 14
茄子: 2688
注册:2012/8/18
存在感:476
跳转到指定楼层
[1L]楼主
Zleepwalking 发表于 2013/5/28 19:43:03 |只看该作者 |倒序浏览
本帖最后由 Zleepwalking 于 2015/3/22 18:28 编辑

2015.3
本贴所包含信息时间过于久远,已废弃。出于保留项目历史原因在此搁置。


        有人提议字数太多了……我尽量缩减篇幅多用表格。
        这些基于RDL的文件(CVS、RSC)是Rocaloid自动生成的,不需要手写。但是高级调教时手动修改会获得更好的调教效果。
        如果你要做高级调教,或者参与开发,或者写一些实用工具的话用得着:



        RDL和XML作用差不多,一种语法标准。

        RDL(Rocaloid Descriptive Language)是我为Rocaloid设计的文件格式。其实RDL没有固定的格式,唯一“固定格式”是

  • 所有关键字、数据用空格,换行或TAB区分,多个空格或换行或TAB被当作一个对待
  • 忽略所有非数据或关键字的字符(或者说当成注释)

        RDL的读写非常容易,只需要拆解字符串就可以了。我没有编译一个专门的DLL用于RDL文件读写,而是写了一个被CVSCommon、RSCCommon使用的RDLIO.vb。

        RDL中常用数据表述结构



        符合RDL标准的文件中常用的数据结构。
        懒得看可以先去看后面给的例子。


数据结构CVS\RSC\CDT中的范例说明
属性Time 0.4属性Time为0.4
结构FreqSet Time 0.8 Freq 600 End以结构名开头,End结尾


定义了一个FreqSet,它的Time属性为0.8,Freq属性为600
结构数组FreqListQ n定义了一个包含了n个FreqSet的数组

FreqList

FreqSet…End

FreqSet…End



End
自动数组DEFList不用设定数量的数组

DEF…End

DEF…End



End
数据表DataPointQ nn为数据表竖排数量,横排数量有专门格式规定。

DataPoint不用End,数据表里直接是数据。

… … …

… … …

… … …

… … …
多值属性#DataMultiple 0.3 1 1可以赋多个值的属性



     解剖一只活生生的CVS


        这是了解CVS文件结构的最快办法,其实你只用读三分之一就懂了。
        ←箭头后面的是注释。
       2013.6.1更新:1.6核心版的更新1中,把Syllable全部改名为TPhone。

#CVS 1.6  ←文件头,版本号
CVS  ←CVS结构开始,包括了所有的信息
        SegmentListQ 5  ←有5个音节
        SegmentList  ←音节列表开始
                Segment  ←第一个音节开始
                        SyllableListQ 3  ←第一个音节有三个音素变化。注:项目初期的时候把音素错写成Syllable了,其实应该是Phone。。后来就将错就错了。
                        SyllableList  ←音素列表
                                Syllable  ←第一个音素
                                        Start Type New Symbol ^[ End  ← 新载入一个^[开始
                                        Dest Type New Symbol a End  ← 过渡到新载入一个a结束
                                        Transition StartRatio 0 EndRatio 1 Time 0.2 End  ← 开始全是^[(过渡率:0),结束时完全过渡到a(过渡率:1),时间0.2秒
                                End ←第一个音素定义完毕
                                Syllable  ←第二个音素
                                        Start Type Preserved Preserved 2 End  ← 从上次结束的a(因为是结束的音素,所以序号是2)开始
                                        Dest Type New Symbol N End  ← 过渡到新载入一个N结束
                                        Transition StartRatio 0 EndRatio 0.7 Time 0.3 End ← 开始全是a(过渡率:0),结束时70%过渡到N(过渡率:0.7),时间0.3秒
                                End ←第二个音素定义完毕
                                Syllable ←第三个音素
                                        Start Type Preserved Preserved 1 End ← 从上次开始的a(因为是开始的音素,所以序号是1)开始
                                        Dest Type Preserved Preserved 2 End ← 过渡到上次结束的N(因为是结束的音素,所以序号是2)结束
                                        Transition StartRatio 0.7 EndRatio 0.8 Time 0.4 End ← 开始70%是a(过渡率:0。7),结束时80%过渡到N(过渡率:0.8),时间0.4秒
                                End ←第四个音素定义完毕
                        End ←音素列表定义完毕
                        FreqListQ 3 ←频率列表数量为3
                        FreqList ←频率列表开始
                                FreqSet Time 0 Freq 258 End ←第一个频率控制点,位于0秒(在音节中的相对位置),频率258HZ
                                FreqSet Time 0.2 Freq 258 End ←第二个频率控制点,位于0.2秒(在音节中的相对位置),频率258HZ
                                FreqSet Time 0.8 Freq 600 End ←第三个频率控制点,位于0.8秒(在音节中的相对位置),频率600HZ
                        End ←频率列表定义完毕
                        Effects ←效果开始定义
                                ElistEnabled False ← 不使用包络列表
                                PresetedEnvelope ADSR ← 使用ADSR包络
                                ADSR Amplitude 2 Attack 0.1 Decline 0.3 Release 0.1 End ← 设定ADSR包络
                        End ←效果定义结束
                        StartTime 0 ← 这个音节在0秒开始
                End ←第一个音节定义结束。。。
                Segment ← 第二个音节开始定义。。。。
                        SyllableListQ 3 ← 之后内容照葫芦画瓢
                        SyllableList
                                Syllable
                                        Start Type New Symbol c@ End
                                        Dest Type New Symbol a End
                                        Transition StartRatio 0 EndRatio 1 Time 0.15 End
                                End
                                Syllable
                                        Start Type Preserved Preserved 2 End
                                        Dest Type New Symbol NG End
                                        Transition StartRatio 0 EndRatio 0.8 Time 0.2 End
                                End
                                Syllable
                                        Start Type Preserved Preserved 1 End
                                        Dest Type Preserved Preserved 2 End
                                        Transition StartRatio 0.8 EndRatio 0.8 Time 0.5 End
                                End
                        End
                        FreqListQ 3
                        FreqList
                                FreqSet Time 0 Freq 340 End
                                FreqSet Time 0.2 Freq 340 End
                                FreqSet Time 0.6 Freq 270 End
                        End
                        Effects
                                ElistEnabled False
                                PresetedEnvelope ADSR
                                ADSR Amplitude 2 Attack 0.1 Decline 0.3 Release 0.1 End
                                Breath ←呼吸声效果定义
                                        Magnitude 2 ← 呼吸声大小倍数为2
                                End ← 呼吸声效果定义结束
                        End
                        StartTime 0.8
                End
                Segment
                        SyllableListQ 3
                        SyllableList
                                Syllable
                                        Start Type New Symbol c3 End
                                        Dest Type New Symbol o End
                                        Transition StartRatio 0 EndRatio 1 Time 0.15 End
                                End
                                Syllable
                                        Start Type Preserved Preserved 2 End
                                        Dest Type New Symbol NG End
                                        Transition StartRatio 0 EndRatio 0.8 Time 0.2 End
                                End
                                Syllable
                                        Start Type Preserved Preserved 1 End
                                        Dest Type Preserved Preserved 2 End
                                        Transition StartRatio 0.8 EndRatio 0.8 Time 0.5 End
                                End
                        End
                        FreqListQ 3
                        FreqList
                                FreqSet Time 0 Freq 270 End
                                FreqSet Time 0.2 Freq 270 End
                                FreqSet Time 0.8 Freq 500 End
                        End
                        Effects
                                ElistEnabled False
                                PresetedEnvelope ADSR
                                ADSR Amplitude 2 Attack 0.1 Decline 0.3 Release 0.1 End
                        End
                        StartTime 2.1
                End
                Segment
                        SyllableListQ 3
                        SyllableList
                                Syllable
                                        Start Type New Symbol c3 End
                                        Dest Type New Symbol e- End
                                        Transition StartRatio 0 EndRatio 1 Time 0.15 End
                                End
                                Syllable
                                        Start Type Preserved Preserved 2 End
                                        Dest Type New Symbol NG End
                                        Transition StartRatio 0 EndRatio 0.8 Time 0.2 End
                                End
                                Syllable
                                        Start Type Preserved Preserved 1 End
                                        Dest Type Preserved Preserved 2 End
                                        Transition StartRatio 0.8 EndRatio 0.8 Time 0.5 End
                                End
                        End
                        FreqListQ 3
                        FreqList
                                FreqSet Time 0 Freq 270 End
                                FreqSet Time 0.2 Freq 270 End
                                FreqSet Time 0.8 Freq 500 End
                        End
                        Effects
                                ElistEnabled False
                                PresetedEnvelope ADSR
                                ADSR Amplitude 2 Attack 0.1 Decline 0.3 Release 0.1 End
                        End
                        StartTime 2.9
                End
                Segment
                        SyllableListQ 3
                        SyllableList
                                Syllable
                                        Start Type New Symbol b@ End
                                        Dest Type New Symbol a End
                                        Transition StartRatio 0 EndRatio 1 Time 0.15 End
                                End
                                Syllable
                                        Start Type Preserved Preserved 2 End
                                        Dest Type New Symbol NG End
                                        Transition StartRatio 0 EndRatio 0.8 Time 0.2 End
                                End
                                Syllable
                                        Start Type Preserved Preserved 1 End
                                        Dest Type Preserved Preserved 2 End
                                        Transition StartRatio 0.8 EndRatio 0.8 Time 3 End
                                End
                        End
                        FreqListQ 5
                        FreqList
                                FreqSet Time 0 Freq 270 End
                                FreqSet Time 0.2 Freq 270 End
                                FreqSet Time 0.6 Freq 340 End
                                FreqSet Time 2 Freq 1200 End
                                FreqSet Time 3.3 Freq 340 End
                        End
                        Effects
                                ElistEnabled True ← 这里启用了包络列表
                                EnvelopeListQ 5 ← 包络列表数量为5
                                EnvelopeList ←包络列表定义开始
                                        EnvelopeSet Time 0 Amplitude 0 End ←包络控制点,时间0秒(在音节中的相对位置),音量为0
                                        EnvelopeSet Time 0.2 Amplitude 2 End ←包络控制点,时间0.2秒(在音节中的相对位置),音量为2
                                        EnvelopeSet Time 0.5 Amplitude 1 End ←包络控制点,时间0.5秒(在音节中的相对位置),音量为1
                                        EnvelopeSet Time 0.6 Amplitude 0.5 End ←包络控制点,时间0.6秒(在音节中的相对位置),音量为0.5
                                        EnvelopeSet Time 0.85 Amplitude 0 End ←包络控制点,时间0.85秒(在音节中的相对位置),音量为0
                                End ← 包络列表定义结束
                                Breath
                                        Magnitude 5
                                End
                        End
                        StartTime 3.8
                End ←第五个音节定义结束
        End←音节列表定义结束
End←CVS定义结束

        注:CVS文件不严格要求空格。但是用空格和TAB处理好缩进可以更清楚。
        CVS的完整结构在源代码中非常清楚。开源后任何人都可以拿到。

        通用CVS格式范例

        如果你认为这种描述方法更有利于理解的话就看这个吧。。。

#CVS 1.6
CVS
  SegmentListQ n
  SegmentList
    Segment
      SyllableListQ n
      SyllableList
        Syllable
          Start Type Preserved/New Symbol xxx Preserved xxx End
          End Type Preserved/New Symbol xxx Preserved xxx End
          Transition StartRatio x EndRatio x Time x End
        End
        Syllable...
      End
      FreqListQ n
      FreqList
        FreqSet Time x Freq x End
        FreqSet...
      End
      Effects
        Shrink xxx
        ForwardCut xxx
        ElistEnabled True/False
        PresetedEnvelope xxx
        ADSREnvelope Attack x Decline x Release x Amplitude x End
        EnvelopeListQ n
        EnvelopeList
          ...
        End
        Breath
          Magnitude x
        End
        OpennessList x x x x x...
      End
      StartTime x
    End
    Segment
      ......
    End
    ......
  End
End

        CVSCommon

        这是写给开发者的。

        CVSCommon是Rocaloid中负责CVS文件读写的组件。读写方式非常容易,要扩展也很简单。下面是读取Syllable结构的代码:
  1.      Public Sub Syllable_Read(ByRef _Syllable As Syllable)

  2.         Dim StrBuff As String

  3.         Do

  4.             StrBuff = Reader.Read()

  5.             Select Case StrBuff

  6.                 Case "Start"

  7.                     SyllableStart_Read(_Syllable.Start)

  8.                 Case "Dest"

  9.                     SyllableDest_Read(_Syllable.Dest)

  10.                 Case "Transition"

  11.                     SyllableTransition_Read(_Syllable.Transition)

  12.                 Case Else

  13.                     'Error

  14.             End Select

  15.         Loop While StrBuff <> "End"

  16.     End Sub
复制代码

        读写是用函数层层嵌套实现的。这种函数几乎已经称为模版了,也许谁能写个工具自动生成读写代码?
        下面是写入CVS中Syllable结构的代码:
  1.      Public Sub Syllable_Write(ByRef _Syllable As Syllable)

  2.         Writer.WriteWord("Syllable")

  3.         Writer.IndentPush()

  4.         Writer.NewLine()

  5.         

  6.         Writer.WriteWord("Start")

  7.         Writer.WriteWord("Type")

  8.         If _Syllable.Start.Type = True Then

  9.             Writer.WriteWord("New")

  10.             Writer.WriteWord("Symbol")

  11.             Writer.WriteWord(_Syllable.Start.Symbol)

  12.         Else

  13.             Writer.WriteWord("Preserved")

  14.             Writer.WriteWord("Preserved")

  15.             Writer.WriteWord(_Syllable.Start.Preserved)

  16.         End If

  17.         Writer.WriteWord("End")

  18.         Writer.NewLine()

  19.         

  20.         Writer.WriteWord("Dest")

  21.         Writer.WriteWord("Type")

  22.         If _Syllable.Dest.Type = True Then

  23.             Writer.WriteWord("New")

  24.             Writer.WriteWord("Symbol")

  25.             Writer.WriteWord(_Syllable.Dest.Symbol)

  26.         Else

  27.             Writer.WriteWord("Preserved")

  28.             Writer.WriteWord("Preserved")

  29.             Writer.WriteWord(_Syllable.Dest.Preserved)

  30.         End If

  31.         Writer.WriteWord("End")

  32.         Writer.NewLine()

  33.         

  34.         Writer.WriteWord("Transition")

  35.         Writer.WriteWord("StartRatio")

  36.         Writer.WriteWord(_Syllable.Transition.StartRatio)

  37.         Writer.WriteWord("EndRatio")

  38.         Writer.WriteWord(_Syllable.Transition.EndRatio)

  39.         Writer.WriteWord("Time")

  40.         Writer.WriteWord(_Syllable.Transition.Time)

  41.         Writer.WriteWord("End")

  42.         

  43.         Writer.IndentPop()

  44.         Writer.NewLine()            

  45.         Writer.WriteWord("End")

  46.         Writer.NewLine()

  47.     End Sub
复制代码

【其实明明可以With Writer。。。。】





知识共享许可协议 除非另有声明,本帖内容采用 署名-非商业-相同方式共享 3.0 许可协议 授权,且需注明出处,所有权利归发帖人。

使用道具 举报

您需要登录后才可以回帖 登录 | 注册/sign up

申请友链|Archiver|iVocaloid - 自由,开放,合作,共享    | 版权持有者点击这里进行举报

GMT+8, 2025/6/7 10:48

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部