2009-06-25 07:16:22 -07:00
|
|
|
/*
|
|
|
|
* UstEvent.cs
|
|
|
|
* Copyright (c) 2009 kbinani
|
|
|
|
*
|
|
|
|
* This file is part of Boare.Lib.Vsq.
|
|
|
|
*
|
|
|
|
* Boare.Lib.Vsq is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the BSD License.
|
|
|
|
*
|
|
|
|
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
2010-03-16 20:14:08 -07:00
|
|
|
#if JAVA
|
|
|
|
package org.kbinani.vsq;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
import java.io.*;
|
|
|
|
import org.kbinani.*;
|
|
|
|
#else
|
|
|
|
using System;
|
2009-09-07 03:44:18 -07:00
|
|
|
using bocoree;
|
2010-03-16 20:14:08 -07:00
|
|
|
using bocoree.java.io;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
2009-06-25 07:16:22 -07:00
|
|
|
namespace Boare.Lib.Vsq {
|
2010-03-16 20:14:08 -07:00
|
|
|
#endif
|
2009-06-25 07:16:22 -07:00
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
#if JAVA
|
|
|
|
public class UstEvent implements Cloneable, Serializable {
|
|
|
|
#else
|
2009-07-29 10:03:20 -07:00
|
|
|
[Serializable]
|
2009-06-25 07:16:22 -07:00
|
|
|
public class UstEvent : ICloneable {
|
2010-03-16 20:14:08 -07:00
|
|
|
#endif
|
2009-09-07 03:44:18 -07:00
|
|
|
public String Tag;
|
2009-06-25 07:16:22 -07:00
|
|
|
public int Length = 0;
|
2009-09-07 03:44:18 -07:00
|
|
|
public String Lyric = "";
|
2009-06-25 07:16:22 -07:00
|
|
|
public int Note = -1;
|
|
|
|
public int Intensity = -1;
|
|
|
|
public int PBType = -1;
|
|
|
|
public float[] Pitches = null;
|
|
|
|
public float Tempo = -1;
|
2009-07-29 10:03:20 -07:00
|
|
|
public UstVibrato Vibrato = null;
|
|
|
|
public UstPortamento Portamento = null;
|
|
|
|
public int PreUtterance = 0;
|
|
|
|
public int VoiceOverlap = 0;
|
|
|
|
public UstEnvelope Envelope = null;
|
2009-09-07 03:44:18 -07:00
|
|
|
public String Flags = "";
|
2009-07-29 10:03:20 -07:00
|
|
|
public int Moduration = 100;
|
2009-09-07 03:44:18 -07:00
|
|
|
public int Index;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
public UstEvent() {
|
2009-07-29 10:03:20 -07:00
|
|
|
}
|
2009-06-25 07:16:22 -07:00
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
public int getLength() {
|
|
|
|
return Length;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLength( int value ) {
|
|
|
|
Length = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Object clone() {
|
2009-06-25 07:16:22 -07:00
|
|
|
UstEvent ret = new UstEvent();
|
2010-03-16 20:14:08 -07:00
|
|
|
ret.setLength( Length );
|
2009-06-25 07:16:22 -07:00
|
|
|
ret.Lyric = Lyric;
|
|
|
|
ret.Note = Note;
|
|
|
|
ret.Intensity = Intensity;
|
|
|
|
ret.PBType = PBType;
|
|
|
|
if ( Pitches != null ) {
|
|
|
|
ret.Pitches = new float[Pitches.Length];
|
|
|
|
for ( int i = 0; i < Pitches.Length; i++ ) {
|
|
|
|
ret.Pitches[i] = Pitches[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret.Tempo = Tempo;
|
2009-07-29 10:03:20 -07:00
|
|
|
if ( Vibrato != null ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
ret.Vibrato = (UstVibrato)Vibrato.clone();
|
2009-07-29 10:03:20 -07:00
|
|
|
}
|
|
|
|
if ( Portamento != null ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
ret.Portamento = (UstPortamento)Portamento.clone();
|
2009-07-29 10:03:20 -07:00
|
|
|
}
|
|
|
|
if ( Envelope != null ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
ret.Envelope = (UstEnvelope)Envelope.clone();
|
2009-07-29 10:03:20 -07:00
|
|
|
}
|
|
|
|
ret.PreUtterance = PreUtterance;
|
|
|
|
ret.VoiceOverlap = VoiceOverlap;
|
|
|
|
ret.Flags = Flags;
|
|
|
|
ret.Moduration = Moduration;
|
|
|
|
ret.Tag = Tag;
|
2009-06-25 07:16:22 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
#if !JAVA
|
|
|
|
public object Clone() {
|
|
|
|
return clone();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
public void print( BufferedWriter sw )
|
|
|
|
#if JAVA
|
|
|
|
throws IOException
|
|
|
|
#endif
|
|
|
|
{
|
2009-09-07 03:44:18 -07:00
|
|
|
if ( this.Index == int.MinValue ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "[#PREV]" );
|
|
|
|
sw.newLine();
|
2009-09-07 03:44:18 -07:00
|
|
|
} else if ( this.Index == int.MaxValue ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "[#NEXT]" );
|
|
|
|
sw.newLine();
|
2009-09-07 03:44:18 -07:00
|
|
|
} else {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "[#" + PortUtil.formatDecimal( "0000", Index ) + "]" );
|
|
|
|
sw.newLine();
|
2009-09-07 03:44:18 -07:00
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "Length=" + Length );
|
|
|
|
sw.newLine();
|
|
|
|
sw.write( "Lyric=" + Lyric );
|
|
|
|
sw.newLine();
|
|
|
|
sw.write( "NoteNum=" + Note );
|
|
|
|
sw.newLine();
|
2009-06-25 07:16:22 -07:00
|
|
|
if ( Intensity >= 0 ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "Intensity=" + Intensity );
|
|
|
|
sw.newLine();
|
2009-06-25 07:16:22 -07:00
|
|
|
}
|
|
|
|
if ( PBType >= 0 && Pitches != null ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "PBType=" + PBType );
|
|
|
|
sw.newLine();
|
|
|
|
sw.write( "Piches=" );
|
2009-06-25 07:16:22 -07:00
|
|
|
for ( int i = 0; i < Pitches.Length; i++ ) {
|
|
|
|
if ( i == 0 ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( Pitches[i] + "" );
|
2009-06-25 07:16:22 -07:00
|
|
|
} else {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "," + Pitches[i] );
|
2009-06-25 07:16:22 -07:00
|
|
|
}
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.newLine();
|
2009-06-25 07:16:22 -07:00
|
|
|
}
|
|
|
|
if ( Tempo > 0 ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "Tempo=" + Tempo );
|
|
|
|
sw.newLine();
|
2009-06-25 07:16:22 -07:00
|
|
|
}
|
2009-07-29 10:03:20 -07:00
|
|
|
if ( Vibrato != null ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( Vibrato.ToString() );
|
|
|
|
sw.newLine();
|
2009-07-29 10:03:20 -07:00
|
|
|
}
|
|
|
|
if ( Portamento != null ) {
|
|
|
|
Portamento.print( sw );
|
|
|
|
}
|
|
|
|
if ( Envelope != null ) {
|
|
|
|
if ( PreUtterance >= 0 ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "PreUtterance=" + PreUtterance );
|
|
|
|
sw.newLine();
|
2009-07-29 10:03:20 -07:00
|
|
|
}
|
|
|
|
if ( VoiceOverlap != 0 ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "VoiceOverlap=" + VoiceOverlap );
|
|
|
|
sw.newLine();
|
2009-07-29 10:03:20 -07:00
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( Envelope.ToString() );
|
|
|
|
sw.newLine();
|
2009-07-29 10:03:20 -07:00
|
|
|
}
|
|
|
|
if ( Flags != "" ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "Flags=" + Flags );
|
|
|
|
sw.newLine();
|
2009-07-29 10:03:20 -07:00
|
|
|
}
|
|
|
|
if ( Moduration >= 0 ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
sw.write( "Moduration=" + Moduration );
|
|
|
|
sw.newLine();
|
2009-07-29 10:03:20 -07:00
|
|
|
}
|
2009-06-25 07:16:22 -07:00
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
|
|
|
/*public VsqEvent convertToVsqEvent( int clock, int internal_id ) {
|
|
|
|
VsqEvent ret = new VsqEvent();
|
|
|
|
ret.Clock = clock;
|
|
|
|
ret.InternalID = internal_id;
|
|
|
|
ret.UstEvent = (UstEvent)this.clone();
|
|
|
|
ret.ID.setLength( Length );
|
|
|
|
ByRef<string> phonetic_symbol = new ByRef<string>( "" );
|
|
|
|
SymbolTable.attatch( Lyric, phonetic_symbol );
|
|
|
|
ret.ID.LyricHandle = new LyricHandle( Lyric, phonetic_symbol.value );
|
|
|
|
ret.ID.Note = Note;
|
|
|
|
ret.ID.Dynamics = Intensity;
|
|
|
|
ret.ID.type = VsqIDType.Anote;
|
|
|
|
return ret;
|
|
|
|
}*/
|
2009-06-25 07:16:22 -07:00
|
|
|
}
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
#if !JAVA
|
2009-06-25 07:16:22 -07:00
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
#endif
|