2009-07-30 08:02:59 -07:00
|
|
|
|
/*
|
|
|
|
|
* UstPortamento.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-07-30 08:02:59 -07:00
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
import java.util.*;
|
|
|
|
|
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.util;
|
|
|
|
|
using bocoree.java.io;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
|
2009-07-30 08:02:59 -07:00
|
|
|
|
namespace Boare.Lib.Vsq {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#endif
|
2009-07-30 08:02:59 -07:00
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if JAVA
|
|
|
|
|
public class UstPortamento implements Cloneable, Serializable {
|
|
|
|
|
#else
|
2009-07-30 08:02:59 -07:00
|
|
|
|
[Serializable]
|
|
|
|
|
public class UstPortamento : ICloneable {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#endif
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public Vector<UstPortamentoPoint> Points = new Vector<UstPortamentoPoint>();
|
2009-07-30 08:02:59 -07:00
|
|
|
|
public int Start;
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
public void print( BufferedWriter sw )
|
|
|
|
|
#if JAVA
|
|
|
|
|
throws IOException
|
|
|
|
|
#endif
|
|
|
|
|
{
|
2009-09-07 03:44:18 -07:00
|
|
|
|
String pbw = "";
|
|
|
|
|
String pby = "";
|
|
|
|
|
String pbm = "";
|
2010-03-16 20:14:08 -07:00
|
|
|
|
int count = Points.size();
|
|
|
|
|
for ( int i = 0; i < count; i++ ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
String comma = (i == 0 ? "" : ",");
|
|
|
|
|
pbw += comma + Points.get( i ).Step;
|
|
|
|
|
pby += comma + Points.get( i ).Value;
|
|
|
|
|
String type = "";
|
2010-03-16 20:14:08 -07:00
|
|
|
|
UstPortamentoType ut = Points.get( i ).Type;
|
|
|
|
|
if ( ut == UstPortamentoType.S ) {
|
|
|
|
|
type = "";
|
|
|
|
|
} else if ( ut == UstPortamentoType.Linear ) {
|
|
|
|
|
type = "s";
|
|
|
|
|
} else if ( ut == UstPortamentoType.R ) {
|
|
|
|
|
type = "r";
|
|
|
|
|
} else if ( ut == UstPortamentoType.J ) {
|
|
|
|
|
type = "j";
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
pbm += comma + type;
|
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
sw.write( "PBW=" + pbw );
|
|
|
|
|
sw.newLine();
|
|
|
|
|
sw.write( "PBS=" + Start );
|
|
|
|
|
sw.newLine();
|
|
|
|
|
sw.write( "PBY=" + pby );
|
|
|
|
|
sw.newLine();
|
|
|
|
|
sw.write( "PBM=" + pbm );
|
|
|
|
|
sw.newLine();
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
public Object clone() {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
UstPortamento ret = new UstPortamento();
|
2010-03-16 20:14:08 -07:00
|
|
|
|
int count = Points.size();
|
|
|
|
|
for ( int i = 0; i < count; i++ ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
ret.Points.add( Points.get( i ) );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
ret.Start = Start;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if !JAVA
|
|
|
|
|
public object Clone() {
|
|
|
|
|
return clone();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-07-30 08:02:59 -07:00
|
|
|
|
/*
|
|
|
|
|
PBW=50,50,46,48,56,50,50,50,50
|
|
|
|
|
PBS=-87
|
|
|
|
|
PBY=-15.9,-20,-31.5,-26.6
|
|
|
|
|
PBM=,s,r,j,s,s,s,s,s
|
|
|
|
|
*/
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public void ParseLine( String line ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
line = line.ToLower();
|
2010-03-16 20:14:08 -07:00
|
|
|
|
String[] spl = PortUtil.splitString( line, '=' );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
if ( spl.Length == 0 ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
String[] values = PortUtil.splitString( spl[1], ',' );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
if ( line.StartsWith( "pbs=" ) ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
Start = PortUtil.parseInt( values[0] );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
} else if ( line.StartsWith( "pbw=" ) ) {
|
|
|
|
|
for ( int i = 0; i < values.Length; i++ ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
if ( i >= Points.size() ) {
|
|
|
|
|
Points.add( new UstPortamentoPoint() );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
UstPortamentoPoint up = Points.get( i );
|
2010-03-16 20:14:08 -07:00
|
|
|
|
up.Step = PortUtil.parseInt( values[i] );
|
2009-09-07 03:44:18 -07:00
|
|
|
|
Points.set( i, up );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
} else if ( line.StartsWith( "pby=" ) ) {
|
|
|
|
|
for ( int i = 0; i < values.Length; i++ ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
if ( i >= Points.size() ) {
|
|
|
|
|
Points.add( new UstPortamentoPoint() );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
UstPortamentoPoint up = Points.get( i );
|
2010-03-16 20:14:08 -07:00
|
|
|
|
up.Value = PortUtil.parseFloat( values[i] );
|
2009-09-07 03:44:18 -07:00
|
|
|
|
Points.set( i, up );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
} else if ( line.StartsWith( "pbm=" ) ) {
|
|
|
|
|
for ( int i = 0; i < values.Length; i++ ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
if ( i >= Points.size() ) {
|
|
|
|
|
Points.add( new UstPortamentoPoint() );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
UstPortamentoPoint up = Points.get( i );
|
2010-03-16 20:14:08 -07:00
|
|
|
|
String search = values[i].ToLower();
|
|
|
|
|
if ( search.Equals( "s" ) ) {
|
|
|
|
|
up.Type = UstPortamentoType.Linear;
|
|
|
|
|
} else if ( search.Equals( "r" ) ) {
|
|
|
|
|
up.Type = UstPortamentoType.R;
|
|
|
|
|
} else if ( search.Equals( "j" ) ) {
|
|
|
|
|
up.Type = UstPortamentoType.J;
|
|
|
|
|
} else {
|
|
|
|
|
up.Type = UstPortamentoType.S;
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
Points.set( i, up );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
} else if ( line.StartsWith( "pbs=" ) ) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if !JAVA
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#endif
|