Skip to content

Commit

Permalink
Added Intonation control
Browse files Browse the repository at this point in the history
  • Loading branch information
EX3exp committed Oct 14, 2024
1 parent 78814e9 commit 5e6ff07
Show file tree
Hide file tree
Showing 26 changed files with 528 additions and 92 deletions.
2 changes: 2 additions & 0 deletions Mirivoice/Assets/Lang/en-US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<system:String x:Key="menu.files.title">Files</system:String>

<system:String x:Key="menu.files.open">Open...</system:String>
<system:String x:Key="menu.files.open.upgrade">Project file is newer than software.
Please upgrade MiriVoice!</system:String>
<system:String x:Key="menu.files.recent">Recent...</system:String>
<system:String x:Key="menu.files.openFailed">An Error occured during open file.
Please Check Log file for more informations.</system:String>
Expand Down
5 changes: 5 additions & 0 deletions Mirivoice/Assets/Lang/ko-KR.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

<system:String x:Key="app.beforeExit">프로젝트가 저장되지 않았어요. 저장할까요?</system:String>
<system:String x:Key="app.openproject">프로젝트 열기</system:String>
<system:String x:Key="menu.files.open.upgrade">
프로젝트의 버전이 소프트웨어의 버전보다 높아요.
MiriVoice를 업데이트해 주세요!
</system:String>

<system:String x:Key="app.saveproject">프로젝트 저장</system:String>

<system:String x:Key="app.defprojectname">새 프로젝트</system:String>
Expand Down
Binary file added Mirivoice/Assets/UI/inton-bos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Mirivoice/Assets/UI/inton-eos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Mirivoice/Assets/UI/inton-no.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Mirivoice/Assets/UI/inton-space.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Mirivoice/Commands/DuplicateLineBoxReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void DoAction()
}
metaIndex++;
}
var lineBox = new LineBoxView(mLinePrototype, l.v, LineNoToBeAdded + 1, l.viewModel.voicerSelector.CurrentDefaultVoicerIndex, metaIndex);
var lineBox = new LineBoxView(mLinePrototype, l.v, LineNoToBeAdded + 1, l.viewModel.voicerSelector.CurrentDefaultVoicerIndex, metaIndex, true);


l.v.LineBoxCollection.Insert(LineNoToBeAdded, lineBox);
Expand Down
14 changes: 7 additions & 7 deletions Mirivoice/Commands/MOriginator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,35 @@ public bool CanRedo()
}
public void ClearRedoMemento()
{
Log.Debug("[Clearing redo memento]");
//Log.Debug("[Clearing redo memento]");
_redoMemento.states.Clear();
}
public void RestoreFromUndoMemento()
{
Log.Debug($"Restoring from undo memento: {_undoMemento}, obj: {obj}");
//Log.Debug($"Restoring from undo memento: {_undoMemento}, obj: {obj}");

_redoMemento.states.Push(obj);
obj = _undoMemento.states.Pop();
UpdateProperties();
Log.Debug("redo Memento: {memento}", _redoMemento);
//Log.Debug("redo Memento: {memento}", _redoMemento);
}

public void Backup(T backup)
{
Log.Debug($"Backup: {backup}");
//Log.Debug($"Backup: {backup}");
this.backup = backup;
_undoMemento.states.Push(backup);
}

public void BackupRedo(T backup)
{
Log.Debug($"Backup Redo: {backup}");
//Log.Debug($"Backup Redo: {backup}");
_redoMemento.states.Push(backup);
}

public void RestoreFromRedoMemento()
{
Log.Debug($"Restoring from memento: {_redoMemento}");
//Log.Debug($"Restoring from memento: {_redoMemento}");
_undoMemento.states.Push(obj);
obj = _redoMemento.states.Pop();
UpdateProperties();
Expand All @@ -80,7 +80,7 @@ public void RestoreFromRedoMemento()

public virtual void UpdateProperties()
{
Log.Information("Updating Properties -- {obj}", obj);
//Log.Information("Updating Properties -- {obj}", obj);
// update ui here
throw new NotImplementedException();
}
Expand Down
6 changes: 3 additions & 3 deletions Mirivoice/Commands/MementoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Execute(bool isRedoing)
if (!isRedoing)
{
_originator.ClearRedoMemento();
//_originator.PrintMemento();
_originator.PrintMemento();

//Log.Debug($"-- exec");
}
Expand All @@ -37,7 +37,7 @@ public void Execute(bool isRedoing)
}
//Log.Debug($"-- Redoing");
_originator.RestoreFromRedoMemento();
//_originator.PrintMemento();
_originator.PrintMemento();
}
}

Expand Down Expand Up @@ -65,7 +65,7 @@ public void UnExecute()
{
//Log.Debug("--- Undo blocked");
}
//_originator.PrintMemento();
_originator.PrintMemento();
}
}
}
28 changes: 28 additions & 0 deletions Mirivoice/Commands/SetComboboxOriginator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Mirivoice.Mirivoice.Core.Format;
using Mirivoice.ViewModels;
using Serilog;
using System;

namespace Mirivoice.Commands
{
public class SetProsodyOriginator : MOriginator<int>
{
private int index;

private readonly MResult v;

public SetProsodyOriginator(ref int index, MResult v) : base(ref index)
{
this.index = index;
this.v = v;
}


public override void UpdateProperties()
{
Log.Debug("[Updating Properties] -- {obj}", obj);
v.NotProcessingSetProsodyCommand = true; // prevent recursion loop
v.Prosody = obj;
}
}
}
3 changes: 2 additions & 1 deletion Mirivoice/Mirivoice.Core/Editor/VoicerSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ public int CurrentDefaultVoicerIndex
OnPropertyChanged(nameof(CurrentVoicer));
OnPropertyChanged(nameof(CurrentDefaultVoicerIndex));

if (lastCulture != new CultureInfo(CurrentVoicer.Info.LangCode))
if (! lastCulture.Equals(new CultureInfo(CurrentVoicer.Info.LangCode)))
{
Log.Debug($"Culture Changed: {lastCulture} -> {new CultureInfo(CurrentVoicer.Info.LangCode)}");
CultureChanged = true;
v.OnVoicerCultureChanged(new CultureInfo(CurrentVoicer.Info.LangCode));
}
Expand Down
143 changes: 139 additions & 4 deletions Mirivoice/Mirivoice.Core/Format/MResult.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
using Mirivoice.Mirivoice.Core.Editor;
using Avalonia.Media;
using Mirivoice.Commands;
using Mirivoice.Mirivoice.Core.Editor;
using Mirivoice.ViewModels;
using Mirivoice.Views;
using ReactiveUI;
using Serilog;
using System.Drawing;
using System.Globalization;
using VYaml.Annotations;

namespace Mirivoice.Mirivoice.Core.Format
{



public enum ProsodyType
{
Undefined = -1,
Bos = 0,
None = 1,
Space = 2,
Eos = 3
}
public class MResult : VoicerSelectingViewModelBase
{
// each phoneme blocks will own One Syllable only
Expand All @@ -32,21 +45,143 @@ public class MResult : VoicerSelectingViewModelBase
//public string[] TTSPhonemes { get; set; } // [kæt] -- [ne], [.ko] -- ʨip̚, [k͈o], jaŋ, .i
public string Word { get; set; }

public int _currentProsodyIndex;
public bool NotProcessingSetProsodyCommand = false;
int lastProsodyIndex;
public override MTextBoxEditor mTextBoxEditor { get; set; }

private ImageBrush _bosIcon;
public ImageBrush BosIcon
{
get => _bosIcon;
set
{
this.RaiseAndSetIfChanged(ref _bosIcon, value);
OnPropertyChanged(nameof(BosIcon));
}

}
private ImageBrush _eosIcon;
public ImageBrush EosIcon
{
get => _eosIcon;
set
{
this.RaiseAndSetIfChanged(ref _eosIcon, value);
OnPropertyChanged(nameof(EosIcon));
}
}

private ImageBrush _nonIcon;
public ImageBrush NonIcon
{
get => _nonIcon;
set
{
this.RaiseAndSetIfChanged(ref _nonIcon, value);
OnPropertyChanged(nameof(NonIcon));
}
}

private ImageBrush _spaceIcon;
public ImageBrush SpaceIcon
{
get => _spaceIcon;
set
{
this.RaiseAndSetIfChanged(ref _spaceIcon, value);
OnPropertyChanged(nameof(SpaceIcon));
}
}

private int _prosody;

bool UndobackupedProsody = false;

public int Prosody
{
get
{
return _prosody;
}
set
{
if (value == -1)
{
return;
}
lastProsodyIndex = _prosody;



if (NotProcessingSetProsodyCommand)
{
if (!UndobackupedProsody)
{


setProsodyCommand.Backup(lastProsodyIndex);
UndobackupedProsody = true;
}
MainManager.Instance.cmd.ExecuteCommand(setProsodyCommand);

UndobackupedProsody = false;
}
else
{
NotProcessingSetProsodyCommand = false;

}
this.RaiseAndSetIfChanged(ref _prosody, value);

OnPropertyChanged(nameof(Prosody));

if (l is not null)
{
l.IsCacheIsVaild = false;

}
}
}

public bool IsEditable { get; set; } = false;
public MResult(string word, string phoneme, bool isEditable): base(phoneme, false)

private readonly LineBoxView l;
public MResult(string word, string phoneme, bool isEditable, ProsodyType prosodyType, LineBoxView l=null): base(phoneme, false)

Check warning on line 150 in Mirivoice/Mirivoice.Core/Format/MResult.cs

View workflow job for this annotation

GitHub Actions / build (win-x64)

Cannot convert null literal to non-nullable reference type.

Check warning on line 150 in Mirivoice/Mirivoice.Core/Format/MResult.cs

View workflow job for this annotation

GitHub Actions / build (linux-x64)

Cannot convert null literal to non-nullable reference type.

Check warning on line 150 in Mirivoice/Mirivoice.Core/Format/MResult.cs

View workflow job for this annotation

GitHub Actions / build (osx-x64)

Cannot convert null literal to non-nullable reference type.
{
this.Word = word;
this.IsEditable = isEditable;
Prosody = (int)prosodyType;
SetIcons();
this.l = l;
SetCommands();
}

public MResult(MResultPrototype mResultPrototype): base(mResultPrototype.Phoneme, false)
public MResult(MResultPrototype mResultPrototype, LineBoxView l) : base(mResultPrototype.Phoneme, false)
{
this.Word = mResultPrototype.Word;
this.IsEditable = mResultPrototype.IsEditable;
this.Prosody = mResultPrototype.ProsodyType;
SetIcons();
this.l = l;
SetCommands();
}

void SetIcons()
{
BosIcon = MainManager.Instance.IconM.BosIcon;
EosIcon = MainManager.Instance.IconM.EosIcon;
NonIcon = MainManager.Instance.IconM.NonIcon;
SpaceIcon = MainManager.Instance.IconM.SpaceIcon;
}

MOriginator<int> setProsodyOriginator;
MementoCommand<int> setProsodyCommand;
void SetCommands()
{
setProsodyOriginator = new SetProsodyOriginator(ref _prosody, this);
setProsodyCommand = new MementoCommand<int>(setProsodyOriginator);
NotProcessingSetProsodyCommand = true;
}
public override void OnVoicerChanged(Voicer value) { }
public override void OnVoicerCultureChanged(CultureInfo culture) { }
Expand Down
Loading

0 comments on commit 5e6ff07

Please sign in to comment.