Updated VOCALOID-related data formats in Multimedia plugin

This commit is contained in:
Michael Becker 2014-10-16 16:10:59 -04:00
parent 3837bcbe34
commit e42d1406d3
3 changed files with 102 additions and 30 deletions

View File

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UniversalEditor.IO;
namespace UniversalEditor.DataFormats.Multimedia.Audio.Voicebank.Vocaloid
{
public class VocaloidIndexDataFormat : DataFormat
{
protected override void LoadInternal(ref ObjectModel objectModel)
{
Reader reader = base.Accessor.Reader;
// Bruno Clara
uint unknown1 = reader.ReadUInt32(); // 0
uint unknown2 = reader.ReadUInt32();
string chunkName = reader.ReadFixedLengthString(4); // DBSe
uint unknown3 = reader.ReadUInt32();
uint unknown4 = reader.ReadUInt32(); // 1
uint unknown5 = reader.ReadUInt32();
uint unknown6 = reader.ReadUInt32(); // 3, subchunk count?
string chunkNamePHDC = reader.ReadFixedLengthString(4);
uint chunkSizePHDC = reader.ReadUInt32(); // total size of PHDC chunk (3927 in Bruno)
uint unknown7 = reader.ReadUInt32(); // 4
uint phonemeCount = reader.ReadUInt32(); // 32
for (uint i = 0; i < phonemeCount; i++)
{
string phonemeName = reader.ReadFixedLengthString(30);
byte phonemeData = reader.ReadByte();
}
string chunkNamePHG2 = reader.ReadFixedLengthString(4);
uint chunkSizePHG2 = reader.ReadUInt32(); // total size of PHG2 chunk (515 in Bruno)
uint groupCount = reader.ReadUInt32(); // 9
for (uint i = 0; i < groupCount; i++)
{
uint groupNameLength = reader.ReadUInt32();
string groupName = reader.ReadFixedLengthString(groupNameLength);
uint groupPhonemeCount = reader.ReadUInt32();
for (uint j = 0; j < phonemeCount; j++)
{
uint unknown8 = reader.ReadUInt32(); // unknown (possibly index into PHDC table?)
uint groupPhonemeNameLength = reader.ReadUInt32();
string groupPhonemeName = reader.ReadFixedLengthString(groupPhonemeNameLength);
}
uint unknown9 = reader.ReadUInt32();
}
// whenever we get to "TDB " chunk
}
protected override void SaveInternal(ObjectModel objectModel)
{
throw new NotImplementedException();
}
}
}

View File

@ -2,21 +2,25 @@ using System;
using UniversalEditor.IO;
using UniversalEditor.ObjectModels.Multimedia.Audio.Voicebank;
using UniversalEditor.ObjectModels.FileSystem;
using UniversalEditor.Accessors;
namespace UniversalEditor.DataFormats.Multimedia.Audio.Voicebank.Vocaloid
{
public class VocaloidVoicebankDataFormat : DataFormat
{
private static DataFormatReference _dfr = null;
public override DataFormatReference MakeReference()
{
DataFormatReference dfr = base.MakeReference();
dfr.Filters.Add("VOCALOID voice bank database", new byte?[][] { new byte?[] { new byte?(70), new byte?(45), new byte?(0), new byte?(0) }, new byte?[] { new byte?(70), new byte?(82), new byte?(77), new byte?(50) } }, new string[] { "*.ddb" });
dfr.Capabilities.Add(typeof(FileSystemObjectModel), DataFormatCapabilities.Load);
dfr.Capabilities.Add(typeof(VoicebankObjectModel), DataFormatCapabilities.All);
return dfr;
if (_dfr == null)
{
_dfr = base.MakeReference();
_dfr.Filters.Add("VOCALOID voice bank database", new byte?[][] { new byte?[] { new byte?(70), new byte?(45), new byte?(0), new byte?(0) }, new byte?[] { new byte?(70), new byte?(82), new byte?(77), new byte?(50) } }, new string[] { "*.ddb" });
_dfr.Capabilities.Add(typeof(VoicebankObjectModel), DataFormatCapabilities.All);
}
return _dfr;
}
protected override void LoadInternal(ref ObjectModel objectModel)
{
BinaryReader br = base.Stream.BinaryReader;
Reader br = base.Accessor.Reader;
VoicebankObjectModel vom = (objectModel as VoicebankObjectModel);
FileSystemObjectModel fsom = (objectModel as FileSystemObjectModel);
@ -42,34 +46,36 @@ namespace UniversalEditor.DataFormats.Multimedia.Audio.Voicebank.Vocaloid
int i = 0;
while (!br.EndOfStream)
{
br.SeekUntil("SND ");
string chunkName = br.ReadFixedLengthString(4);
uint chunkSize = br.ReadUInt32();
uint dataSize = chunkSize - 8;
byte[] chunkData = br.ReadBytes(dataSize);
string SND_ = br.ReadFixedLengthString(4);
if (SND_ == "SND ")
switch (chunkName)
{
int sign = br.ReadInt32();
int size = br.ReadInt32();
int freq = br.ReadInt32();
short channels = br.ReadInt16();
int dummy = br.ReadInt32();
byte[] data = br.ReadBytes(size - 18);
if (fsom != null)
case "SND ":
{
fsom.Files.Add(i.ToString() + ".raw", data);
Reader r = new Reader(new MemoryAccessor(chunkData));
int size = r.ReadInt32();
int freq = r.ReadInt32();
short channels = br.ReadInt16();
int dummy = br.ReadInt32();
// TODO: test this
byte[] data = br.ReadBytes(size - 18);
if (fsom != null)
{
fsom.Files.Add(i.ToString() + ".raw", data);
}
Console.WriteLine("found sound file " + i.ToString() + ":");
Console.WriteLine(" size: " + size.ToString());
Console.WriteLine(" freq: " + freq.ToString());
Console.WriteLine(" channels: " + channels.ToString());
Console.WriteLine(" unknown_int32: " + dummy.ToString());
i++;
break;
}
Console.WriteLine("found sound file " + i.ToString() + ":");
Console.WriteLine(" sign: " + sign.ToString());
Console.WriteLine(" size: " + size.ToString());
Console.WriteLine(" freq: " + freq.ToString());
Console.WriteLine(" channels: " + channels.ToString());
Console.WriteLine(" unknown_int32: " + dummy.ToString());
i++;
}
else
{
break;
}
}
}

View File

@ -77,6 +77,8 @@
<Compile Include="DataFormats\Multimedia\Audio\Synthesized\SPC\SPC700Memory.cs" />
<Compile Include="DataFormats\Multimedia\Audio\Synthesized\SPC\SPC700Registers.cs" />
<Compile Include="DataFormats\Multimedia\Audio\VoicebankPhonemeDictionary\PhonemeDictionaryXMLDataFormat.cs" />
<Compile Include="DataFormats\Multimedia\Audio\Voicebank\Vocaloid\VocaloidIndexDataFormat.cs" />
<Compile Include="DataFormats\Multimedia\Audio\Voicebank\Vocaloid\VocaloidVoicebankDataFormat.cs" />
<Compile Include="DataFormats\Multimedia\Palette\Adobe\ACODataFormat.cs" />
<Compile Include="DataFormats\Multimedia\Palette\Adobe\ASEDataFormat.cs" />
<Compile Include="DataFormats\Multimedia\Palette\GIMP\GPLDataFormat.cs" />