Skip to content

Commit

Permalink
Merge pull request #2 from Live2D/develop
Browse files Browse the repository at this point in the history
Update to Cubism 5 SDK MotionSync Plugin for Native R1
  • Loading branch information
itoh-at-live2d-com authored May 30, 2024
2 parents 28f5742 + 545ad3a commit 9de5581
Show file tree
Hide file tree
Showing 55 changed files with 606 additions and 268 deletions.
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [5-r.1] - 2024-05-30

### Added

* Add right orientation to the fixed orientations in the iOS and Android app.

### Changed

* Disabled `stat` due to effect of Apple Privacy Manifests.
* Cleaned up the include directives.
* Change functions used to ensure line breaks are done correctly.
* Change the usage part of function `fmod()` to function `CubismMath.ModF()`.
* Change the Japanese sound file to one with a sampling frequency of 48 kHz.
* Change so that the sound file does not automatically play when loading the model.
* `MotionSyncAnalysisConfig_CRI::AudioLevelEffectRatio` has been marked as `Unused`.

### Fixed

* Fix `EXC_BAD_ACCESS` when running on iOS.
* The reason is that recording and playback are separate threads and access the buffer at the same time.
* Therefore, mutexes were used to prevent simultaneous access.
* Fix an issue that sample audio output is only for speakers on iOS.
* Fix the method of locking the app to prevent the model from being cut off on the iPad.

### Removed

* Remove `CubismMotionSync::SetAudioLevelEffectRatio` function.


## [5-r.1-beta.2] - 2024-01-25

### Added
Expand Down Expand Up @@ -34,4 +63,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* New released!


[5-r.1]: https://github.com/Live2D/CubismNativeMotionSyncComponentsDev/compare/5-r.1-beta.2...5-r.1
[5-r.1-beta.2]: https://github.com/Live2D/CubismNativeMotionSyncComponentsDev/compare/5-r.1-beta.1...5-r.1-beta.2
34 changes: 34 additions & 0 deletions Core/README.ja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[English](README.md) / [日本語](README.ja.md)

---

# Live2D Cubism MotionSync Core

このフォルダーには、モーションシンクを利用したネイティブアプリケーションを開発するためのヘッダーおよびプラットフォーム固有のライブラリファイルが含まれています。


## Library List

| プラットフォーム | アーキテクチャ | dll | lib | パス | 注記 |
| --- | --- | --- | --- | --- | --- |
| Android | ARM64 || | Android/arm64-v8a | |
| Android | ARMv7 || | Android/armeabi-v7a | このライブラリは現在非推奨で、近日中に削除される予定です。 |
| Android | x86 || | Android/x86 | |
| Android | x86_64 || | Android/x86_64 | |
| iOS | ARM64 | || iOS/xxx-iphoneos | iOS Devices |
| iOS | x86_64 | || iOS/xxx-iphonesimulator | iOS Simulator |
| macOS | ARM64 || | macOS | |
| macOS | x86_64 || | macOS | |
| Windows | x86 || | Windows/x86 | |
| Windows | x86_64 || | Windows/x86_64 | |


### 呼び出し規約

*Windows/x86*のダイナミックリンクライブラリを使用する場合は、呼び出し規約として明示的に`__stdcall`を使用してください。

---

[![CRIWARE for Games](CRIWARELOGO_1.png)](https://game.criware.jp/)

このソフトウェアには、(株)CRI・ミドルウェアの「CRIWARE (R)」が使用されています。
6 changes: 4 additions & 2 deletions Core/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Live2D Cubism MotionSync Engine
[English](README.md) / [日本語](README.ja.md)

This folder contains header files and platform-specific library files for using the motion sync plug-in.
# Live2D Cubism MotionSync Core

This folder contains header files and platform-specific library files for developing native applications with using the motion sync.


## Library List
Expand Down
10 changes: 1 addition & 9 deletions Framework/src/CubismMotionSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void CubismMotionSync::UpdateParameters(CubismModel *model, csmFloat32 deltaTime
Analyze(model, processIndex);

// Reset counter.
_processorInfoList[processIndex]._currentRemainTime = fmod(_processorInfoList[processIndex]._currentRemainTime, processorDeltaTime);
_processorInfoList[processIndex]._currentRemainTime = CubismMath::ModF(_processorInfoList[processIndex]._currentRemainTime, processorDeltaTime);

for (csmUint32 targetIndex = 0; targetIndex < _data->GetSetting(processIndex).cubismParameterList.GetSize(); targetIndex++)
{
Expand Down Expand Up @@ -159,14 +159,6 @@ void CubismMotionSync::SetSampleRate(csmUint32 processIndex, csmFloat32 sampleRa
}
}

void CubismMotionSync::SetAudioLevelEffectRatio(csmUint32 processIndex, csmFloat32 audioLevelEffectRatio)
{
if (processIndex < _processorInfoList.GetSize())
{
_processorInfoList[processIndex]._audioLevelEffectRatio = audioLevelEffectRatio;
}
}

EngineType CubismMotionSync::ToEngineType(csmString engineName)
{
EngineType engineType = EngineType_Unknown;
Expand Down
8 changes: 0 additions & 8 deletions Framework/src/CubismMotionSync.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ class CubismMotionSync
*/
void SetSampleRate(csmUint32 processIndex, csmFloat32 sampleRate);

/**
* @brief プロセッサのaudioLevelEffectRatioを設定
*
* @param[in] processIndex インデックス
* @param[in] audioLevelEffectRatio 設定する値
*/
void SetAudioLevelEffectRatio(csmUint32 processIndex, csmFloat32 audioLevelEffectRatio);

private:
struct CubismProcessorInfo
{
Expand Down
28 changes: 15 additions & 13 deletions Framework/src/CubismMotionSyncAudioBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,33 +145,33 @@ void CubismMotionSyncAudioBuffer<T>::Resize(csmUint32 bufferSize, csmBool useOut

// 満タン状態かどうか判断するためにbuffer + 1の大きさで確保する
_ringBuffer = static_cast<T*>(CSM_MALLOC(sizeof(T) * (_ringBufferSize)));
for (csmUint32 i = 0; i < _ringBufferSize; i++)
{
CSM_PLACEMENT_NEW(&_ringBuffer[i]) T();
}


// メモリ確保確認
if (!_ringBuffer)
{
_ringBufferSize = 0;
return;
}

for (csmUint32 i = 0; i < _ringBufferSize; i++)
{
CSM_PLACEMENT_NEW(&_ringBuffer[i]) T();
}

if (useOutputBuffer)
{
// リングバッファで使用するバッファは必ず一つ空ける必要がある
_outputBuffer = static_cast<T*>(CSM_MALLOC(sizeof(T) * _ringBufferSize - 1));
for (csmUint32 i = 0; i < _ringBufferSize - 1; i++)
{
CSM_PLACEMENT_NEW(&_outputBuffer[i]) T();
}


// メモリ確保確認
if (!_outputBuffer)
{
_ringBufferSize = 0;
Release();
_ringBuffer = NULL;
}

for (csmUint32 i = 0; i < _ringBufferSize - 1; i++)
{
CSM_PLACEMENT_NEW(&_outputBuffer[i]) T();
}
}
}
Expand Down Expand Up @@ -261,6 +261,7 @@ void CubismMotionSyncAudioBuffer<T>::Release()
_outputBuffer[i].~T();
}
CSM_FREE(_outputBuffer);
_outputBuffer = NULL;
_outputBufferSize = 0;
}
if (_ringBuffer)
Expand All @@ -270,7 +271,8 @@ void CubismMotionSyncAudioBuffer<T>::Release()
_ringBuffer[i].~T();
}
CSM_FREE(_ringBuffer);
_ringBufferSize = 1;
_ringBuffer = NULL;
_ringBufferSize = 0;
_begin = 0;
_end = 0;
_usingBufferSize = 0;
Expand Down
2 changes: 1 addition & 1 deletion Framework/src/CubismMotionSyncData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#include "CubismMotionSyncData.hpp"
#include <CubismMotionSyncDataJson.hpp>
#include "CubismMotionSyncDataJson.hpp"

//--------- LIVE2D NAMESPACE ------------
namespace Live2D { namespace Cubism { namespace Framework { namespace MotionSync {
Expand Down
14 changes: 11 additions & 3 deletions Framework/src/CubismMotionSyncEngineController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/

// Apple Privacy Manifestsの影響のため無効化
#define USE_STAT_LIB 0

#include "CubismMotionSyncEngineController.hpp"
#if USE_STAT_LIB
#include <sys/stat.h>
#endif
#include "CubismMotionSyncEngineVersion.hpp"
#include "CubismMotionSyncEngineCri.hpp"
#ifndef CSM_MOTIONSYNC_USE_STATIC_LIB
#include "Lib/CubismMotionSyncEngineLib.hpp"
#ifdef CSM_MOTIONSYNC_USE_STATIC_LIB
#else
#include "Lib/CubismMotionSyncEngineStaticLib.hpp"
#endif

Expand All @@ -20,16 +26,18 @@ csmMap<EngineType, ICubismMotionSyncEngine*> CubismMotionSyncEngineController::_

ICubismMotionSyncEngine* CubismMotionSyncEngineController::InstallEngine(csmString dllFilePath)
{
struct stat statBuf;

#ifndef CSM_MOTIONSYNC_USE_STATIC_LIB
// 動的ライブラリの使用

#if USE_STAT_LIB
struct stat statBuf;

// 渡されたパスにファイルが存在するかチェック
if (stat(dllFilePath.GetRawString(), &statBuf) != 0)
{
return NULL;
}
#endif

ICubismMotionSyncEngineLib* engineHandle = CSM_NEW CubismMotionSyncEngineLib();
if (!engineHandle->LoadLibrary(dllFilePath.GetRawString()))
Expand Down
2 changes: 1 addition & 1 deletion Framework/src/CubismMotionSyncProcessorCRI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CubismMotionSyncProcessorCri : public ICubismMotionSyncProcessor
* @param samples 解析したい音声データ
* @param blendRatio ブレンド率(0.0f~1.0f)
* @param smoothing スムージングの値(1~100)
* @param audioLevelEffectRatio 音量の大きさが口の開閉に与える影響度(0.0~1.0)
* @param audioLevelEffectRatio 音量の大きさが口の開閉に与える影響度(0.0~1.0) ※現在未使用。互換性のため残される
*
* @return 解析結果のインスタンス
*/
Expand Down
2 changes: 1 addition & 1 deletion Framework/src/CubismMotionSyncProcessorCri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CubismMotionSyncProcessorCri : public ICubismMotionSyncProcessor
* @param samples 解析したい音声データ
* @param blendRatio ブレンド率(0.0f~1.0f)
* @param smoothing スムージングの値(1~100)
* @param audioLevelEffectRatio 音量の大きさが口の開閉に与える影響度(0.0~1.0)
* @param audioLevelEffectRatio 音量の大きさが口の開閉に与える影響度(0.0~1.0) ※現在未使用。互換性のため残される
*
* @return 解析結果のインスタンス
*/
Expand Down
2 changes: 1 addition & 1 deletion Framework/src/ICubismMotionSyncEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#pragma once

#include "CubismMotionSyncEngineVersion.hpp"
#include "Lib/CubismMotionSyncEngineLib.hpp"
#include "Lib/ICubismMotionSyncEngineLib.hpp"
#include "Lib/CubismMotionSyncUtil.hpp"
#include "Type/csmVector.hpp"

Expand Down
1 change: 1 addition & 0 deletions Framework/src/Lib/CubismMotionSyncConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ struct MotionSyncAnalysisConfig_CRI
Csm::csmInt32 Smoothing;

/** Audio level effect ratio. */
/** Unused */
Csm::csmFloat32 AudioLevelEffectRatio;
};

Expand Down
2 changes: 1 addition & 1 deletion Framework/src/Lib/CubismMotionSyncUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#define _CRT_SECURE_NO_WARNINGS

#include "CubismMotionSyncEngineLib.hpp"
#include "ICubismMotionSyncEngineLib.hpp"
#include "CubismMotionSyncEngineMappingInfo.hpp"

//--------- LIVE2D NAMESPACE ------------
Expand Down
9 changes: 8 additions & 1 deletion NOTICE.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@

## [制限事項] Cubism SDK MotionSync Plugin for Native の対応環境について (2023-12-21)


iPhoneSimulator環境でマイク入力を動作させる場合は、事前に入力デバイスの接続をしてください。


## [制限事項] Visual Studio 2022 17.10以降での動作について (2024-05-30)

Visual C++ コンパイラのバージョンの変更により、Visual Studio 2022 17.10を利用したWindowsビルドが一部エラーとなる問題を確認しております。

この問題は次回リリースバージョンで修正される予定です。
ご利用の際は修正をお待ちいただくか、Visual Studio 2022 17.9 以前のバージョンをご利用ください。

---

©Live2D
8 changes: 8 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

When executing microphone input in iPhoneSimulator, please connect the input device in advance.


## [Limitations] Regarding operation with Visual Studio 2022 17.10 and later (2024-05-30)

We have confirmed an issue where the Windows build using Visual Studio 2022 17.10 results in errors due to a change in the Visual C++ compiler version.

This issue is planned to be fixed in the next release version. When using this, please wait for the fix or use a version of Visual Studio 2022 prior to 17.9.


---

©Live2D
Loading

0 comments on commit 9de5581

Please sign in to comment.