Skip to content

Commit

Permalink
[Docs] Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
melanchall committed May 14, 2022
1 parent 0141f59 commit ab84ef6
Show file tree
Hide file tree
Showing 33 changed files with 117 additions and 118 deletions.
71 changes: 44 additions & 27 deletions Docs/articles/composing/Pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,72 +50,89 @@ var pattern = new PatternBuilder()
// The length of all main theme's notes within four first bars is
// triplet eight so set it which will free us from necessity to specify
// the length of each note explicitly
.SetNoteLength(MusicalTimeSpan.Eighth.Triplet())

// Anchor current time (start of the pattern) to jump to it
// when we'll start to program bass part
.Anchor()

// We will add notes relative to G#3.
// Instead of Octave.Get(3).GSharp it is possible to use Note.Get(NoteName.GSharp, 3)
.SetRootNote(Octave.Get(3).GSharp)

// Add first three notes and repeat them seven times which will
// give us two bars of the main theme
// G#3
.Note(Interval.Zero) // +0 (G#3)
.Note(Interval.Five) // +5 (C#4)
.Note(Interval.Eight) // +8 (E4)
.Repeat(3, 7) // repeat three previous notes seven times
// G#3
.Note(Interval.Zero) // +0 (G#3)
.Note(Interval.Five) // +5 (C#4)
.Note(Interval.Eight) // +8 (E4)
.Repeat(3, 7) // repeat three previous notes seven times
// Add notes of the next two bars
// G#3
.Note(Interval.One) // +1 (A3)
.Note(Interval.Five) // +5 (C#4)
.Note(Interval.Eight) // +8 (E4)
.Repeat(3, 1) // repeat three previous notes
.Note(Interval.One) // +1 (A3)
.Note(Interval.Six) // +6 (D4)
.Note(Interval.Ten) // +10 (F#4)
.Repeat(3, 1) // repeat three previous notes
// reaching the end of third bar
.Note(Interval.Zero) // +0 (G#3)
.Note(Interval.Four) // +4 (C4)
.Note(Interval.Ten) // +10 (F#4)
.Note(Interval.Zero) // +0 (G#3)
.Note(Interval.Five) // +5 (C#4)
.Note(Interval.Eight) // +8 (E4)
.Note(Interval.Zero) // +0 (G#3)
.Note(Interval.Five) // +5 (C#4)
// G#3
.Note(Interval.One) // +1 (A3)
.Note(Interval.Five) // +5 (C#4)
.Note(Interval.Eight) // +8 (E4)
.Repeat(3, 1) // repeat three previous notes
.Note(Interval.One) // +1 (A3)
.Note(Interval.Six) // +6 (D4)
.Note(Interval.Ten) // +10 (F#4)
.Repeat(3, 1) // repeat three previous notes
// reaching the end of third bar
.Note(Interval.Zero) // +0 (G#3)
.Note(Interval.Four) // +4 (C4)
.Note(Interval.Ten) // +10 (F#4)
.Note(Interval.Zero) // +0 (G#3)
.Note(Interval.Five) // +5 (C#4)
.Note(Interval.Eight) // +8 (E4)
.Note(Interval.Zero) // +0 (G#3)
.Note(Interval.Five) // +5 (C#4)
.Note(Intervaln.Seven) // +7 (D#4)
.Note(-Interval.Two) // -2 (F#3)
.Note(Interval.Four) // +4 (C4)
.Note(Interval.Seven) // +7 (D#4)
.Note(-Interval.Two) // -2 (F#3)
.Note(Interval.Four) // +4 (C4)
.Note(Interval.Seven) // +7 (D#4)
// Now we will program bass part. To start adding notes from the
// beginning of the pattern we need to move to the anchor we set
// above
.MoveToFirstAnchor()

// First two chords have whole length
.SetNoteLength(MusicalTimeSpan.Whole)

// insert a chord relative to
.Chord(bassChord, Octave.Get(2).CSharp) // C#2 (C#2, C#3)
.Chord(bassChord, Octave.Get(1).B) // B1 (B1, B2)
// Remaining four chords has half length
.SetNoteLength(MusicalTimeSpan.Half)

.Chord(bassChord, Octave.Get(1).A) // A1 (A1, A2)
.Chord(bassChord, Octave.Get(1).FSharp) // F#1 (F#1, F#2)
.Chord(bassChord, Octave.Get(1).GSharp) // G#1 (G#1, G#2)
.Repeat() // repeat the previous chord
// Build a pattern that can be then saved to a MIDI file
.Build();
```

[Build](xref:Melanchall.DryWetMidi.Composing.PatternBuilder.Build) method returns an instance of [Pattern](xref:Melanchall.DryWetMidi.Composing.Pattern). Pattern can be transformed or altered by methods in [PatternUtilities](xref:Melanchall.DryWetMidi.Composing.PatternUtilities).

Also see [Extension methods](xref:Melanchall.DryWetMidi.Composing.Pattern#extensionmethods) section of the [Pattern](xref:Melanchall.DryWetMidi.Composing.Pattern) API.
Pattern can be then saved to [MidiFile](xref:Melanchall.DryWetMidi.Core.MidiFile) (via [ToFile](xref:Melanchall.DryWetMidi.Composing.Pattern.ToFile*) method) or [TrackChunk](xref:Melanchall.DryWetMidi.Core.TrackChunk) (via [ToTrackChunk](xref:Melanchall.DryWetMidi.Composing.Pattern.ToTrackChunk*) method). You need to provide a [tempo map](xref:Melanchall.DryWetMidi.Interaction.TempoMap). Also you can optionally specify the channel that should be set to events. The default channel is `0`.

Also please see [Extension methods](xref:Melanchall.DryWetMidi.Composing.Pattern#extensionmethods) section of the [Pattern](xref:Melanchall.DryWetMidi.Composing.Pattern) API.
2 changes: 1 addition & 1 deletion Docs/articles/devices/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ All classes that interact with devices work with interfaces mentioned above, so

MIDI devices API classes are placed in the [Melanchall.DryWetMidi.Multimedia](xref:Melanchall.DryWetMidi.Multimedia) namespace.

To understand what is input and output device in DryWetMIDI take a look at following image:
To understand what is an input and an output device in DryWetMIDI take a look at the following image:

![Devices](images/Devices.png)

Expand Down
Binary file modified Docs/articles/devices/images/CustomInputDevice.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 modified Docs/articles/devices/images/Devices.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 modified Docs/articles/devices/images/DevicesConnector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions Docs/articles/music-theory/Chord.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Please note that some interval sets start from number greater than zero. Current
|`5`|`0 7`|
|`7b5`<br/>`dom7dim5`<br/>`7dim5`|`0 4 6 10`|
|`ø`<br/>`ø7`<br/>`m7b5`<br/>`min7dim5`<br/>`m7dim5`<br/>`min7b5`<br/>`m7b5`|`0 3 6 10`|
|`aug7`|`0 4 8 10`|
|`aug7`<br/>`7#5`<br/>`7+5`|`0 4 8 10`|
|`dim7`|`0 3 6 9`|
|`add9`|`0 4 7 14`|
|`minAdd9`<br/>`mAdd9`|`0 3 7 14`|
Expand All @@ -97,4 +97,7 @@ Please note that some interval sets start from number greater than zero. Current
|`9`|`0 4 7 10 14`|
|`9sus2`|`0 2 7 10 14`|
|`9sus4`|`0 5 7 10 14`|
|`11`|`0 4 7 10 14 17`|
|`11`|`0 4 7 10 14 17`|
|`7b9`|`0 4 7 10 13`|
|`add11`|`0 4 7 17`|
|`7#11`<br/>`7+11`<br/>`7(#11)`<br/>`7aug11`|`0 4 7 10 18`|
66 changes: 20 additions & 46 deletions Docs/articles/playback/Data-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,90 +13,64 @@ uid: a_playback_datatrack

Let's take a look at the following events sequence to play:

```image
...A.....B...
```

where `A` and `B` means _Note On_ and _Note Off_ events correspondingly. `.` means any other MIDI event.
![MIDI data](images/NotesTrack-Initial.png)

`Playback` class has [TrackNotes](xref:Melanchall.DryWetMidi.Multimedia.Playback.TrackNotes) property. If its value is `true`, playback will internally construct notes based on input objects to play. So in our example one note will be constructed:

```image
...[A.....B]...
```
![Note](images/NotesTrack-Note.png)

Now let's imagine a playback's time is at some point and we want to jump to a new one (with [MoveToTime](xref:Melanchall.DryWetMidi.Multimedia.Playback.MoveToTime(Melanchall.DryWetMidi.Interaction.ITimeSpan)) for example):

```image
.│.[A..║..B]...
│ ↑
└────┘
```
![Move to note with TrackNotes set to false](images/NotesTrack-ToNote-False.png)

If we now jump to a new time that falls in the middle of the note, behavior of the playback will be different depending on `TrackNotes` property value. In case of the property value is `false` nothing special will happen, just the current time of the playback will be changed. But if we set `TrackNotes` to `true`, new _Note On_ event will be generated and played when we jump to the new time:

First vertical line shows the current time of playback. If we now jump to a new time that falls in the middle of second note (second vertical line), behavior of the playback will be different depending on `TrackNotes` property value. In case of the property value is `false` nothing special will happen, just the current time of the playback will be changed. But if we set `TrackNotes` to `true`, new _Note On_ event will be generated and played when we jump to the new time.
![Move to note with TrackNotes set to true](images/NotesTrack-ToNote-True.png)

The same situation with opposite case:

```image
...[A..│..B].║.
│ ↑
└────┘
```
![Move from note with TrackNotes set to true](images/NotesTrack-FromNote-True.png)

So we want here to jump from the middle of a note to the time after the note. As in previous example if `TrackNotes` is `false`, just the current time of the playback will be changed. But if in case of `true`, new _Note Off_ event will be generated and played when we jump to the new time.

So `TrackNotes = true` tells playback to track time jumps when the current time pointer of the playback either leaves a note or enters one to finish or start the note correspondingly.

Of course in cases like this:

```image
...[A..│..B].[..A..║.].B...
│ ↑
└─────────┘
```
![Move from note to note with TrackNotes set to true](images/NotesTrack-FromNoteToNote.png)

playback will play both _Note Off_ event (since we're leaving the first note) and _Note On_ one (since we're entering the second note).

## MIDI parameters values tracking

Let's imagine we have the following events sequence to play:

```image
...P...Q...A...
```

where `P` and `Q` means _Program Change_ events, `A` means _Note On_ event and `.` means any other MIDI event.
![Program changes](images/ProgTrack-Initial.png)

And now we want to jump from the current time of a playback to a new time (with [MoveToTime](xref:Melanchall.DryWetMidi.Multimedia.Playback.MoveToTime(Melanchall.DryWetMidi.Interaction.ITimeSpan)) for example):

```image
...P.│.Q.║.A...
│ ↑
└───┘
```
![Move after B program](images/ProgTrack-AfterB.png)

So by the current time `P` event is played and the current program corresponds to `P`. If the playback just change the current time, `A` will be played using program `P` which is wrong since `Q` should be used.
So by the current time `A` event is played and the current program corresponds to `A`. If the playback just change the current time, the note will be played using program `A` which may be wrong since the note is actually is under `B` program influence.

To track a program `Playback` class has [TrackProgram](xref:Melanchall.DryWetMidi.Multimedia.Playback.TrackProgram) property. If it's set to `false`, nothing will happen except changing the current time. All following notes can sound incorrectly due to possibly skipped program changes.

But if we set `TrackProgram` to `true`, playback will play required _Program Change_ event immediately after time changed. So in our example `Q` will be played and then playback continues from new time.
But if we set `TrackProgram` to `true`, playback will play required _Program Change_ event immediately after time changed. So in our example `B` will be played and then playback continues from new time:

![Move after B program with TrackProgram set to true](images/ProgTrack-AfterB-2.png)

Program tracking works in opposite direction too of course:

```image
...P.║.Q.│.A...
↑ │
└───┘
```
![Move after A program with TrackProgram set to true](images/ProgTrack-AfterA.png)

We have program `Q` active at the current time. But when we jump to a new time (before `Q` but after `P`), `P` event will be played.
We have program `B` active at the current time. But when we jump to a new time (before `B` but after `A`), `A` event will be played.

`Playback` can track at now three MIDI parameters:

* program (see [ProgramChangeEvent](xref:Melanchall.DryWetMidi.Core.ProgramChangeEvent))
* pitch bend (see [PitchBendEvent](xref:Melanchall.DryWetMidi.Core.PitchBendEvent))
* control value (see [ControlChangeEvent](xref:Melanchall.DryWetMidi.Core.ControlChangeEvent))
* [program](xref:Melanchall.DryWetMidi.Core.ProgramChangeEvent);
* [pitch bend](xref:Melanchall.DryWetMidi.Core.PitchBendEvent);
* [control value](xref:Melanchall.DryWetMidi.Core.ControlChangeEvent).

We have discussed tracking program above. But tracking the remaining two parameters is absolutely the same. To track pitch bend value there is [TrackPitchValue](xref:Melanchall.DryWetMidi.Multimedia.Playback.TrackPitchValue) property. To track control value there is [TrackControlValue](xref:Melanchall.DryWetMidi.Multimedia.Playback.TrackControlValue) property.
We have discussed program tracking above. But tracking the remaining two parameters is absolutely the same. To track pitch bend value there is [TrackPitchValue](xref:Melanchall.DryWetMidi.Multimedia.Playback.TrackPitchValue) property. To track control value there is [TrackControlValue](xref:Melanchall.DryWetMidi.Multimedia.Playback.TrackControlValue) property.

Of course all these parameters are tracked separately for each MIDI channel and in addition to this control value tracked separately for each control number.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 Docs/articles/playback/images/NotesTrack-Note.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Docs/articles/tools/images/NotesMerger/NotesMergerTolerance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion DryWetMidi/Multimedia/DevicesConnector/DevicesConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ namespace Melanchall.DryWetMidi.Multimedia
{
/// <summary>
/// Provides a way to connect an input MIDI device to an output MIDI devices to redirect all
/// incoming events from the input device to the output ones.
/// incoming events from the input device to the output ones. More info in the
/// <see href="xref:a_dev_connector">Devices connector</see> article.
/// </summary>
public sealed class DevicesConnector
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
namespace Melanchall.DryWetMidi.Multimedia
{
/// <summary>
/// Provides methods to connect MIDI devices.
/// Provides methods to connect MIDI devices. More info in the
/// <see href="xref:a_dev_connector">Devices connector</see> article.
/// </summary>
public static class DevicesConnectorUtilities
{
Expand Down
6 changes: 2 additions & 4 deletions DryWetMidi/Multimedia/DevicesWatcher/DevicesWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
namespace Melanchall.DryWetMidi.Multimedia
{
/// <summary>
/// Provides a way to watch devices adding/removing in the system.
/// Provides a way to watch devices adding/removing in the system. More info in the
/// <see href="xref:a_dev_watcher">Devices watcher</see> article.
/// </summary>
/// <remarks>
/// Please see <see href="xref:a_dev_watcher">Devices watcher</see> article to learn more.
/// </remarks>
public sealed class DevicesWatcher
{
#region Events
Expand Down
5 changes: 4 additions & 1 deletion DryWetMidi/Multimedia/InputDevice/IInputDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
namespace Melanchall.DryWetMidi.Multimedia
{
/// <summary>
/// Represents an abstract input MIDI device.
/// Represents an abstract input MIDI device. More info in the
/// <see href="xref:a_dev_overview">Devices</see> and
/// <see href="xref:a_dev_input">Input device</see> articles.
/// </summary>
/// <seealso cref="InputDevice"/>
public interface IInputDevice
{
/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion DryWetMidi/Multimedia/InputDevice/InputDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
namespace Melanchall.DryWetMidi.Multimedia
{
/// <summary>
/// Represents an input MIDI device.
/// Represents an input MIDI device. More info in the
/// <see href="xref:a_dev_overview">Devices</see> and
/// <see href="xref:a_dev_input">Input device</see> articles.
/// </summary>
public sealed class InputDevice : MidiDevice, IInputDevice
{
Expand Down
5 changes: 4 additions & 1 deletion DryWetMidi/Multimedia/OutputDevice/IOutputDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
namespace Melanchall.DryWetMidi.Multimedia
{
/// <summary>
/// Represents an abstract output MIDI device.
/// Represents an abstract output MIDI device. More info in the
/// <see href="xref:a_dev_overview">Devices</see> and
/// <see href="xref:a_dev_output">Output device</see> articles.
/// </summary>
/// <seealso cref="OutputDevice"/>
public interface IOutputDevice
{
/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion DryWetMidi/Multimedia/OutputDevice/OutputDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
namespace Melanchall.DryWetMidi.Multimedia
{
/// <summary>
/// Represents an output MIDI device.
/// Represents an output MIDI device. More info in the
/// <see href="xref:a_dev_overview">Devices</see> and
/// <see href="xref:a_dev_output">Output device</see> articles.
/// </summary>
public sealed class OutputDevice : MidiDevice, IOutputDevice
{
Expand Down
Loading

0 comments on commit ab84ef6

Please sign in to comment.