Skip to content

Commit

Permalink
Reorganize projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
stakira committed Aug 29, 2021
1 parent 594d5fc commit bff7f52
Show file tree
Hide file tree
Showing 57 changed files with 276 additions and 576 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Serilog;

namespace OpenUtau.Core {
class DocManager {
public class DocManager {
DocManager() {
Project = new UProject();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Serilog;

namespace OpenUtau.Core {
class PlaybackManager : ICmdSubscriber {
public class PlaybackManager : ICmdSubscriber {
private WaveOutEvent outDevice;
private WaveOutEvent testDevice;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Diagnostics;

namespace OpenUtau.Classic {
class Plugin {
public class Plugin {
public string Name;
public string Executable;
public bool AllNotes;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace OpenUtau.Classic {

class VoicebankInstaller {
public class VoicebankInstaller {
readonly string basePath;
readonly Action<double, string> progress;

Expand Down Expand Up @@ -67,23 +67,6 @@ public void LoadArchive(string path) {
}
}

static Encoding DetectArchiveFileEncoding(string path) {
Encoding encoding = Encoding.GetEncoding(1252);
var options = new ReaderOptions {
ArchiveEncoding = new ArchiveEncoding(encoding, encoding)
};
var detector = new Ude.CharsetDetector();
using (var archive = ArchiveFactory.Open(path, options)) {
foreach (var entry in archive.Entries) {
byte[] buffer = encoding.GetBytes(entry.Key);
detector.Feed(buffer, 0, buffer.Length);
}
}
detector.DataEnd();
Log.Information($"{path} charset: {detector.Charset} confidence: {detector.Confidence}");
return Encoding.GetEncoding(detector.Charset);
}

static string HashPath(string path) {
string file = Path.GetFileName(path);
string dir = Path.GetDirectoryName(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Text;

namespace OpenUtau.Classic {
class VoicebankLoader {
public class VoicebankLoader {
class FileLoc {
public string file;
public int lineNumber;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace OpenUtau.Core.Formats {
public enum ProjectFormats { Unknown, Vsq3, Vsq4, Ust, Ustx };

static class Formats {
public static class Formats {
const string ustMatch = "[#SETTING]";
const string ustxMatch = "ustxVersion";
const string vsq3Match = VSQx.vsq3NameSpace;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using OpenUtau.Core.Ustx;

namespace OpenUtau.Core.Formats {
class Ustx {
public class Ustx {
public static readonly Version kUstxVersion = new Version(0, 1);

public static void AddBuiltInExpressions(UProject project) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Media.Imaging;
using System.Collections.Generic;
using OpenUtau.Classic;
using OpenUtau.Core.Ustx;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using OpenUtau.Core.Ustx;

namespace OpenUtau.Core.Formats {
static class VSQx {
public static class VSQx {
public const string vsq3NameSpace = @"http://www.yamaha.co.jp/vocaloid/schema/vsq3/";
public const string vsq4NameSpace = @"http://www.yamaha.co.jp/vocaloid/schema/vsq4/";

Expand Down
46 changes: 15 additions & 31 deletions OpenUtau/Core/Formats/Wave.cs → OpenUtau.Core/Formats/Wave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@

using OpenUtau.Core.Ustx;

namespace OpenUtau.Core.Formats
{
static class Wave
{
public static UWavePart CreatePart(string filepath)
{
foreach(var part in DocManager.Inst.Project.parts)
{
namespace OpenUtau.Core.Formats {
public static class Wave {
public static UWavePart CreatePart(string filepath) {
foreach (var part in DocManager.Inst.Project.parts) {
var _part = part as UWavePart;
if (_part != null && _part.FilePath == filepath)
{
return new UWavePart()
{
if (_part != null && _part.FilePath == filepath) {
return new UWavePart() {
FilePath = filepath,
FileDurTick = _part.FileDurTick,
Duration = _part.Duration,
Expand All @@ -32,17 +26,13 @@ public static UWavePart CreatePart(string filepath)
}
}
WaveStream stream = null;
try
{
try {
stream = new AudioFileReader(filepath);
}
catch
{
} catch {
return null;
}
int durTick = DocManager.Inst.Project.MillisecondToTick(1000.0 * stream.Length / stream.WaveFormat.AverageBytesPerSecond);
UWavePart uwavepart = new UWavePart()
{
UWavePart uwavepart = new UWavePart() {
FilePath = filepath,
FileDurTick = durTick,
Duration = durTick,
Expand All @@ -52,14 +42,12 @@ public static UWavePart CreatePart(string filepath)
return uwavepart;
}

public static float[] BuildPeaks(UWavePart part, System.ComponentModel.BackgroundWorker worker)
{
public static float[] BuildPeaks(UWavePart part, System.ComponentModel.BackgroundWorker worker) {
const double peaksRate = 4000;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
float[] peaks;
using (var stream = new AudioFileReader(part.FilePath))
{
using (var stream = new AudioFileReader(part.FilePath)) {
int channels = part.Channels;
double peaksSamples = (int)((double)stream.Length / stream.WaveFormat.BlockAlign / stream.WaveFormat.SampleRate * peaksRate);
peaks = new float[(int)(peaksSamples + 1) * channels];
Expand All @@ -74,20 +62,16 @@ public static float[] BuildPeaks(UWavePart part, System.ComponentModel.Backgroun
int peaksPos = 0;
double bufferPos = 0;
float lmax = 0, lmin = 0, rmax = 0, rmin = 0;
while ((readed = converted.Read(buffer, 0, 4096)) != 0)
{
while ((readed = converted.Read(buffer, 0, 4096)) != 0) {
readPos += readed;
for (int i = 0; i < readed; i += channels)
{
for (int i = 0; i < readed; i += channels) {
lmax = Math.Max(lmax, buffer[i]);
lmin = Math.Min(lmin, buffer[i]);
if (channels > 1)
{
if (channels > 1) {
rmax = Math.Max(rmax, buffer[i + 1]);
rmin = Math.Min(rmin, buffer[i + 1]);
}
if (i > bufferPos)
{
if (i > bufferPos) {
lmax = -lmax; lmin = -lmin; rmax = -rmax; rmin = -rmin; // negate peaks to fipped waveform
peaks[peaksPos * channels] = lmax == 0 ? lmin : lmin == 0 ? lmax : (lmin + lmax) / 2;
peaks[peaksPos * channels + 1] = rmax == 0 ? rmin : rmin == 0 ? rmax : (rmin + rmax) / 2;
Expand Down
126 changes: 126 additions & 0 deletions OpenUtau.Core/OpenUtau.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{25A15BBB-A9EF-449E-9C12-67F5C28BD088}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenUtau.Core</RootNamespace>
<AssemblyName>OpenUtau.Core</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Classes\DocManager.cs" />
<Compile Include="Classes\PlaybackManager.cs" />
<Compile Include="Classic\Plugin.cs" />
<Compile Include="Classic\PluginLoader.cs" />
<Compile Include="Classic\VoiceBank.cs" />
<Compile Include="Classic\VoicebankInstaller.cs" />
<Compile Include="Classic\VoicebankLoader.cs" />
<Compile Include="Commands\ExpCommands.cs" />
<Compile Include="Commands\NoteCommands.cs" />
<Compile Include="Commands\Notifications.cs" />
<Compile Include="Commands\PartCommands.cs" />
<Compile Include="Commands\ProjectCommands.cs" />
<Compile Include="Commands\TrackCommands.cs" />
<Compile Include="Commands\UCommand.cs" />
<Compile Include="Formats\Formats.cs" />
<Compile Include="Formats\Midi.cs" />
<Compile Include="Formats\Ust.cs" />
<Compile Include="Formats\USTx.cs" />
<Compile Include="Formats\UtauSoundbank.cs" />
<Compile Include="Formats\VSQx.cs" />
<Compile Include="Formats\Wave.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Render\NAudio\AudioStreamReader.cs" />
<Compile Include="Render\NAudio\EnvelopeSampleProvider.cs" />
<Compile Include="Render\NAudio\MemorySampleProvider.cs" />
<Compile Include="Render\NAudio\RenderItemSampleProvider.cs" />
<Compile Include="Render\NAudio\SequencingSampleProvider.cs" />
<Compile Include="Render\NAudio\TrackSampleProvider.cs" />
<Compile Include="Render\RenderCache.cs" />
<Compile Include="Render\RenderEngine.cs" />
<Compile Include="Render\RenderItem.cs" />
<Compile Include="ResamplerDriver\DriverModels.cs" />
<Compile Include="ResamplerDriver\Factorys\CppDriver.cs" />
<Compile Include="ResamplerDriver\Factorys\ExeDriver.cs" />
<Compile Include="ResamplerDriver\Factorys\SharpDriver.cs" />
<Compile Include="ResamplerDriver\ResamplerDriver.cs" />
<Compile Include="ThirdParty\Deque.cs" />
<Compile Include="Ustx\UExpression.cs" />
<Compile Include="Ustx\UNote.cs" />
<Compile Include="Ustx\UPart.cs" />
<Compile Include="Ustx\UPhoneme.cs" />
<Compile Include="Ustx\UProject.cs" />
<Compile Include="Ustx\USinger.cs" />
<Compile Include="Ustx\UTrack.cs" />
<Compile Include="Util\Base64.cs" />
<Compile Include="Util\IniFileClass.cs" />
<Compile Include="Util\MusicMath.cs" />
<Compile Include="Util\PathManager.cs" />
<Compile Include="Util\Preferences.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NAudio">
<Version>2.0.1</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
</PackageReference>
<PackageReference Include="Serilog">
<Version>2.10.0</Version>
</PackageReference>
<PackageReference Include="SharpCompress">
<Version>0.28.3</Version>
</PackageReference>
<PackageReference Include="System.IO">
<Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.IO.Packaging">
<Version>5.0.0</Version>
</PackageReference>
<PackageReference Include="WanaKanaSharp">
<Version>0.1.1</Version>
</PackageReference>
<PackageReference Include="xxHashSharp">
<Version>1.0.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
36 changes: 36 additions & 0 deletions OpenUtau.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenUtau.Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenUtau.Core")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("25a15bbb-a9ef-449e-9c12-67f5c28bd088")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
using OpenUtau.Core.ResamplerDriver.Factorys;

namespace OpenUtau.Core.ResamplerDriver {
internal interface IResamplerDriver {
public interface IResamplerDriver {
byte[] DoResampler(DriverModels.EngineInput Args, out string output);
DriverModels.EngineInfo GetInfo();
}

internal class ResamplerDriver {
public class ResamplerDriver {
public static IResamplerDriver Load(string filePath) {
string ext = Path.GetExtension(filePath).ToLower();
if (!File.Exists(filePath)) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit bff7f52

Please sign in to comment.