Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Modification #47

Merged
merged 8 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/markdowns/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
href: start/gen/channel-base-api.md
- name: トラックベースAPI
href: start/gen/track-base-api.md
- name: バッファリング可能な音声生成
href: start/gen/track-base-api-partial.md
- name: WAV出力
href: start/wav.md
- name: Ver 3.0.0への移行
Expand All @@ -22,4 +24,5 @@
items:
- name: SMSCフォーマットとは?
href: smsc/what-is-the-smsc.md
- name: SMSCシリアライズ・デシリアライズ
- name: SMSCシリアライズ・デシリアライズ
href: smsc/serializer.md
20 changes: 13 additions & 7 deletions src/SoundMaker/FormatBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ internal BitDepthBuilder(FormatBuilder builder)
};

/// <summary>
/// sets a bit depth(BitRateType) to format. 量子化ビット数を指定する。
/// Sets a bit depth(BitRateType) to format. <br/>
/// 量子化ビット数を指定する。
/// </summary>
/// <param name="bitDepth">value</param>
/// <returns>builder</returns>
Expand Down Expand Up @@ -63,7 +64,8 @@ internal SamplingFrequencyBuilder(FormatBuilder builder)
};

/// <summary>
/// sets a sampling frequency to format. サンプリング周波数を指定する。
/// Sets a sampling frequency to format. <br/>
/// サンプリング周波数を指定する。
/// </summary>
/// <param name="frequency">sampling frequency</param>
/// <returns>builder</returns>
Expand Down Expand Up @@ -95,9 +97,10 @@ internal ChannelTypeBuilder(FormatBuilder builder)
};

/// <summary>
/// sets a count fo channels to format.
/// Sets a count fo channels to format.<br/>
/// チャンネル数を設定する(1: モノラル、2: ステレオ)
/// </summary>
/// <param name="count">count of channels</param>
/// <param name="count">count of channels<br/>チャンネル数</param>
/// <returns></returns>
/// <exception cref="ArgumentException">The count value must be either 1 or 2.</exception>
public FormatBuilder WithChannelCount(int count)
Expand All @@ -112,7 +115,8 @@ public FormatBuilder WithChannelCount(int count)
}

/// <summary>
/// create an instance of builder. ビルダのインスタンスを作成する。
/// Create an instance of builder. <br/>
/// ビルダのインスタンスを作成する。
/// </summary>
/// <returns>builder</returns>
public static SamplingFrequencyBuilder Create()
Expand All @@ -122,7 +126,8 @@ public static SamplingFrequencyBuilder Create()
}

/// <summary>
/// build to FormatChunk. FormatChunkにビルドする。
/// Build to FormatChunk. <br/>
/// FormatChunkにビルドする。
/// </summary>
/// <returns>FormatChunk</returns>
public FormatChunk ToFormatChunk()
Expand All @@ -131,7 +136,8 @@ public FormatChunk ToFormatChunk()
}

/// <summary>
/// build to SoundFormat. SoundFormatにビルドする。
/// Build to SoundFormat. <br/>
/// SoundFormatにビルドする。
/// </summary>
/// <returns>SoundFormat</returns>
public SoundFormat ToSoundFormat()
Expand Down
8 changes: 4 additions & 4 deletions src/SoundMaker/ScoreData/SMSC/SMSCFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public static class SMSCFormat
/// Reads SMSC data.<br/>
/// SMSCデータを読み込む。
/// </summary>
/// <param name="data">SMSC data. SMSCデータ</param>
/// <returns>The read results. 読み取り結果</returns>
/// <param name="data">SMSC data. <br/>SMSCデータ</param>
/// <returns>The read results. <br/>読み取り結果</returns>
public static SMSCReadResult Read(string data)
{
var lexer = new Lexer(data);
Expand All @@ -23,8 +23,8 @@ public static SMSCReadResult Read(string data)
/// Outputs SMSC data.<br/>
/// SMSCデータを出力する。
/// </summary>
/// <param name="components">Sound components to write. 書き込むサウンドコンポーネント</param>
/// <returns>SMSC data. SMSCデータ</returns>
/// <param name="components">Sound components to write. <br/>書き込むサウンドコンポーネント</param>
/// <returns>SMSC data. <br/>SMSCデータ</returns>
public static string Serialize(IEnumerable<ISoundComponent> components)
{
return SMSCSerializer.Serialize(components);
Expand Down
4 changes: 2 additions & 2 deletions src/SoundMaker/Sounds/ChannelType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
public enum ChannelType
{
/// <summary>
/// monaural(1ch) モノラル1ch
/// monaural(1ch) <br/>モノラル1ch
/// </summary>
Monaural,
/// <summary>
/// stereo(2ch) ステレオ2ch
/// stereo(2ch) <br/>ステレオ2ch
/// </summary>
Stereo
}
15 changes: 8 additions & 7 deletions src/SoundMaker/Sounds/IWave.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
namespace SoundMaker.Sounds;

/// <summary>
/// interface for wave. 波を表すインターフェイス
/// Interface for wave. 波を表すインターフェイス
/// </summary>
public interface IWave
{
/// <summary>
/// get length of bytes of wave data. 波形データのバイト列の長さを取得するメソッド。
/// Get the length of bytes of wave data. <br/>波形データのバイト列の長さを取得するメソッド。
/// </summary>
/// <param name="bitRate">quantization bit rate. 量子化ビット数</param>
/// <returns>length of bytes of wave data.</returns>
/// <param name="bitRate">Quantization bit rate. <br/>量子化ビット数</param>
/// <returns>Length of bytes of wave data.</returns>
int GetLengthOfBytes(BitRateType bitRate);

/// <summary>
/// get the array of bytes of wave data. 波形データのバイト列を取得するメソッド。
/// Get the array of bytes of wave data. <br/>波形データのバイト列を取得するメソッド。
/// </summary>
/// <param name="bitRate">quantization bit rate. 量子化ビット数</param>
/// <returns>bytes of wave data. 波形データのバイト列 : byte[]</returns>
/// <param name="bitRate">Quantization bit rate. <br/>量子化ビット数</param>
/// <returns>Array of bytes of wave data. <br/>波形データのバイト列 : byte[]</returns>
byte[] GetBytes(BitRateType bitRate);
}
25 changes: 9 additions & 16 deletions src/SoundMaker/Sounds/MixerBase.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
using SoundMaker.Sounds.SoundChannels;

namespace SoundMaker.Sounds;

/// <summary>
/// provides a base class for a mixer to inherit from. ミキサーの抽象基底クラス
/// Provides a base class for a mixer to inherit from. <br/>ミキサーの抽象基底クラス
/// </summary>
public abstract class MixerBase
/// <param name="channels">List of sound channels (read-only). <br/>音声チャンネルのリスト(読み取り専用)</param>
public abstract class MixerBase(IReadOnlyList<ISoundChannel> channels)
{
/// <summary>
/// constructor コンストラクタ
/// </summary>
/// <param name="channels">音声チャンネルのリスト(読み取り専用)</param>
public MixerBase(IReadOnlyList<ISoundChannel> channels)
{
Channels = channels;
}

/// <summary>
/// チャンネルのリスト
/// List of channels. <br/>チャンネルのリスト
/// </summary>
protected IReadOnlyList<ISoundChannel> Channels { get; }
protected IReadOnlyList<ISoundChannel> Channels { get; } = channels;

/// <summary>
/// 音のフォーマット
/// Sound format. <br/>音のフォーマット
/// </summary>
protected SoundFormat Format { get; }

/// <summary>
/// 各チャンネルの波形データで一番長い配列の長さを返すメソッド。
/// Method to return the length of the longest array in each channel's waveform data. <br/>各チャンネルの波形データで一番長い配列の長さを返すメソッド。
/// </summary>
/// <returns>最長の配列の長さ : int</returns>
/// <returns>Length of the longest array. <br/>最長の配列の長さ : int</returns>
protected int GetMaxWaveLength()
{
var max = 0;
Expand Down
18 changes: 6 additions & 12 deletions src/SoundMaker/Sounds/MonauralMixer.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
using SoundMaker.Sounds.SoundChannels;

namespace SoundMaker.Sounds;

/// <summary>
/// mix waves to monaural wave. モノラル音声をミックスするクラス。
/// Mix waves to monaural wave. <br/>モノラル音声をミックスするクラス。
/// </summary>
public class MonauralMixer : MixerBase
/// <param name="channels">Channels. <br/>チャンネルのリスト(読み取り専用)</param>
public class MonauralMixer(IReadOnlyList<ISoundChannel> channels) : MixerBase(channels)
{
/// <summary>
/// constructor. コンストラクタ
/// </summary>
/// <param name="channels">channels. チャンネルのリスト(読み取り専用)</param>
public MonauralMixer(IReadOnlyList<ISoundChannel> channels) : base(channels)
{
}

private object LockObject { get; } = new object();

/// <summary>
/// mix ミックスする。
/// Mix. <br/>ミックスする。
/// </summary>
/// <returns>the mixed wave of monaural. モノラルの波形データ : MonauralWave</returns>
/// <returns>The mixed wave of monaural. <br/>モノラルの波形データ : MonauralWave</returns>
public MonauralWave Mix()
{
var result = Enumerable.Repeat((short)0, GetMaxWaveLength()).ToArray();
Expand Down
19 changes: 10 additions & 9 deletions src/SoundMaker/Sounds/MonauralWave.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
namespace SoundMaker.Sounds;

/// <summary>
/// monaural wave. モノラル波形データを表すクラス。
/// Monaural wave. <br/>モノラル波形データを表すクラス。
/// </summary>
public class MonauralWave : IWave
{
/// <summary>
/// constructor. コンストラクタ
/// Constructor. <br/>コンストラクタ
/// </summary>
/// <param name="wave">the collection of wave data. 波形データを表す配列</param>
/// <param name="wave">The collection of wave data. <br/>波形データを表す配列</param>
public MonauralWave(IReadOnlyCollection<short> wave)
{
var argumentIntegers = wave.ToArray();
Expand All @@ -24,9 +25,9 @@ public MonauralWave(IReadOnlyCollection<short> wave)
public int Volume { get; private set; } = 100;

/// <summary>
/// change volume this. 音量を変更するメソッド
/// Change volume. <br/>音量を変更するメソッド
/// </summary>
/// <param name="volume">音量(0 ~ 100)</param>
/// <param name="volume">Volume (0 ~ 100). <br/>音量(0 ~ 100)</param>
public void ChangeVolume(int volume)
{
volume = volume < 0 ? 0 : volume;
Expand All @@ -39,9 +40,9 @@ public void ChangeVolume(int volume)
}

/// <summary>
/// append deferent MonauralWave. 別の波形データを末尾に繋げるメソッド。
/// Append different MonauralWave. <br/>別の波形データを末尾に繋げるメソッド。
/// </summary>
/// <param name="wave">monaural wave.モノラルの波形データ</param>
/// <param name="wave">Monaural wave. <br/>モノラルの波形データ</param>
public void Append(MonauralWave wave)
{
Wave = Wave.Concat(wave.GetWave()).ToArray();
Expand Down Expand Up @@ -74,9 +75,9 @@ public byte[] GetBytes(BitRateType bitRate)
}

/// <summary>
/// get the wave. 音の波形データを取得するメソッド。
/// Get the wave. <br/>音の波形データを取得するメソッド。
/// </summary>
/// <returns>the wave. 波形データ : short[]</returns>
/// <returns>The wave. <br/>波形データ : short[]</returns>
public short[] GetWave()
{
var result = new short[Wave.Length];
Expand Down
3 changes: 2 additions & 1 deletion src/SoundMaker/Sounds/SamplingFrequencyType.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace SoundMaker.Sounds;
/// <summary>
/// the type which is expressed sampling frequency of the sound. サンプリング周波数の種類を表す列挙型
/// The type which is expressed sampling frequency of the sound. <br/>
/// サンプリング周波数の種類を表す列挙型
/// </summary>
public enum SamplingFrequencyType
{
Expand Down
13 changes: 7 additions & 6 deletions src/SoundMaker/Sounds/Score/BasicSoundComponentBase.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
using SoundMaker.Sounds.WaveTypes;

namespace SoundMaker.Sounds.Score;

/// <summary>
/// provides a base class for a basic sound component to inherit from. 音符・休符など音の基本部品を表す抽象基底クラス
/// Provides a base class for a basic sound component to inherit from. <br/>音符・休符など音の基本部品を表す抽象基底クラス
/// </summary>
public abstract class BasicSoundComponentBase : ISoundComponent
{
/// <summary>
/// constructor コンストラクタ
/// Constructor. <br/>コンストラクタ
/// </summary>
/// <param name="length">length (ex. "quarter" note) 長さ(音楽的な、「四分」音符、「全」休符のような長さを表す。)</param>
/// <param name="isDotted">is note/rest dotted. 付点かを表す論理型</param>
/// <param name="length">Length (ex. "quarter" note). <br/>長さ(音楽的な、「四分」音符、「全」休符のような長さを表す。)</param>
/// <param name="isDotted">Is note/rest dotted. <br/>付点かを表す論理型</param>
public BasicSoundComponentBase(LengthType length, bool isDotted)
{
Length = length;
IsDotted = isDotted;
}

/// <summary>
/// length (ex. "quarter" note) 長さ(音楽的な、「四分」音符、「全」休符のような長さを表す。)
/// Length (ex. "quarter" note). <br/>長さ(音楽的な、「四分」音符、「全」休符のような長さを表す。)
/// </summary>
public LengthType Length { get; }

/// <summary>
/// note/rest is dotted. 付点かを表す論理型
/// Note/rest is dotted. <br/>付点かを表す論理型
/// </summary>
public bool IsDotted { get; }

Expand Down
38 changes: 18 additions & 20 deletions src/SoundMaker/Sounds/Score/ISoundComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,46 @@
namespace SoundMaker.Sounds.Score;

/// <summary>
/// interface for sound components. 音の部品を表すインターフェイス
/// Interface for sound components. <br/>音の部品を表すインターフェイス
/// </summary>
public interface ISoundComponent
{
/// <summary>
/// return length of the sound array. 音の配列の長さを取得するメソッド。
/// Return length of the sound array. <br/>音の配列の長さを取得するメソッド。
/// </summary>
/// <param name="format">format of the sound.音のフォーマット</param>
/// <param name="tempo">quarter note/rest per minute. 一分間の四分音符・休符の数</param>
/// <returns>length of array. 配列の長さ : int</returns>
/// <param name="format">Format of the sound. <br/>音のフォーマット</param>
/// <param name="tempo">Quarter note/rest per minute. <br/>一分間の四分音符・休符の数</param>
/// <returns>Length of array. <br/>配列の長さ : int</returns>
/// <exception cref="ArgumentOutOfRangeException">Tempo must be non-negative and greater than 0.</exception>
int GetWaveArrayLength(SoundFormat format, int tempo);

/// <summary>
/// generate the wave of wave type. 波形の種類に基づいて波形データの配列を生成するメソッド。
/// Generate the wave of wave type. <br/>波形の種類に基づいて波形データの配列を生成するメソッド。
/// </summary>
/// <param name="format">format of the sound.音のフォーマット</param>
/// <param name="tempo">quarter note/rest per minute. 一分間の四分音符・休符の数</param>
/// <param name="length">length of the array. 配列の長さ</param>
/// <param name="waveType">type of wave.波形の種類</param>
/// <returns>data of wave. 波形データ : short[]</returns>
/// <param name="format">Format of the sound. <br/>音のフォーマット</param>
/// <param name="tempo">Quarter note/rest per minute. <br/>一分間の四分音符・休符の数</param>
/// <param name="length">Length of the array. <br/>配列の長さ</param>
/// <param name="waveType">Type of wave. <br/>波形の種類</param>
/// <returns>Data of wave. <br/>波形データ : short[]</returns>
/// <exception cref="ArgumentOutOfRangeException">Tempo must be non-negative and greater than 0.</exception>
/// <exception cref="ArgumentOutOfRangeException">Length must be non-negative.</exception>
short[] GenerateWave(SoundFormat format, int tempo, int length, WaveTypeBase waveType);

/// <summary>
/// generate the wave of wave type. 波形の種類に基づいて波形データの配列を生成するメソッド。
/// Generate the wave of wave type. <br/>波形の種類に基づいて波形データの配列を生成するメソッド。
/// </summary>
/// <param name="format">format of the sound.音のフォーマット</param>
/// <param name="tempo">quarter note/rest per minute. 一分間の四分音符・休符の数</param>
/// <param name="waveType">type of wave.波形の種類</param>
/// <returns>data of wave. 波形データ : short[]</returns>
/// <param name="format">Format of the sound. <br/>音のフォーマット</param>
/// <param name="tempo">Quarter note/rest per minute. <br/>一分間の四分音符・休符の数</param>
/// <param name="waveType">Type of wave. <br/>波形の種類</param>
/// <returns>Data of wave. <br/>波形データ : short[]</returns>
/// <exception cref="ArgumentOutOfRangeException">Tempo must be non-negative and greater than 0.</exception>
short[] GenerateWave(SoundFormat format, int tempo, WaveTypeBase waveType);

/// <summary>
/// Creates a clone of the sound component. <br/>
/// サウンドコンポーネントのクローンを作成するメソッド。
/// Creates a clone of the sound component. <br/>サウンドコンポーネントのクローンを作成するメソッド。
/// </summary>
/// <returns>
/// A new instance of the sound component with the same properties. <br/>
/// 同じプロパティを持つサウンドコンポーネントの新しいインスタンス
/// A new instance of the sound component with the same properties. <br/>同じプロパティを持つサウンドコンポーネントの新しいインスタンス
/// </returns>
ISoundComponent Clone();
}
Loading
Loading