About Loop Tuner

 Loop Tuner is designed for files in PCM format (such as .WAV and Ogg Vorbis).
 Loop Tuner is a tool that generates such information.

 The generated information is the file name of PCM format file with suffix .sli (for example, se001.wav for se001.wav.sli), and when opening PCM format file with WaveSoundBuffer Class it will be loaded automatically.

What is a seamless loop

 Even if you do not use the loop tuner, you can use the WaveSoundBuffer.looping property to perform loop playback. However, this only allows you to do a simple loop: play from the beginning of the sound, play back to the end, and then return to the beginning.
 By using the loop tuner, you can set a loop that plays back to an arbitrary point in the sound and then returns to an arbitrary point, as shown below. This can be used when looping a song or when starting the engine, such as when looping a sound, so that the sound cannot be played repeatedly from the beginning.

lt_seamless_loop.png

 In this case, if the timing of the repetition is not strictly adjusted, crack noises such as "small" and "small" will occur at the loop position. Since the loop tuner has a function to support the detailed adjustment of this timing, it can be adjusted easily and a seamless (seamless) loop can be realized.
 Also, in some rare cases, no matter how much adjustment you make, you may not be able to remove this noise, but with loop tuners, a very short (about 50ms) crossfade right near the link reduces this noise.

Conditional links

 You can use this conditional link if you are playing a song in a loop, but when certain conditions are reached, you want to exit the loop and proceed to the next melody.
 In the loop tuner, information for changing the sound playback position is called a "link", but you can add conditions to this link.
 The loop tuner can manage 16 "flags", and these flags have values between 0 and 9999. For these arbitrary links, "conditions" such as "the XX flag is XX", "XX flag is not XX", "XX flag is XX or less", etc. If the match, follow the link, you can set.
 Flags can be tested by changing their values on the loop tuner, and can also be manipulated from script using WaveSoundBuffer.flags Property.

label

 You can set a "label" for a purpose such as "I want to generate an event when the playback position reaches a specific location."
 Passing the label will trigger an WaveSoundBuffer.onLabel event. Since the label name is passed to the event parameter, you can know which label has passed.

 Also, by setting a special "expression" to the label, you can increase or decrease the value of the flag or set the value when passing through the label.
 By combining with the above "conditional link", you can play a specific section only four times.

Links, labels and buffering

 Kirikiri's WaveSoundBuffer constantly buffers sound. After decoding (reading from a file or decompressing a compressed music file), it does not play it out immediately, but rather stores it in a memory called a buffer and then plays it back.
 In other words, decoding is always performed ahead of the actual playback position, and there is a gap of up to 2 seconds in the standard setting.
 The condition of the link is tested at the time of this decoding, so even if the flag is manipulated, the effect will actually take effect up to 2 seconds later. In other words, during playback, changing the conditions immediately before the link, up to 2 seconds before, may not affect the link, so care must be taken.
 "Up to 2 seconds" means that in some cases it may be shorter. If the CPU has enough power and decodes enough, it will keep about 2 seconds, but if the CPU is deprived of other processing and the decoding is delayed, it may be less than 2 seconds.

 For labels, the label event occurs when the actual "playback position" reaches that location, whereas the label "expression" is executed at the "decode position". Note that has reached that location, so be careful.

Readable format

 The loop tuner can handle the following PCM format files at this time.

The loop tuner uses the same plugin as the Kirikiri core. In the standard distribution configuration, each plug-in is automatically detected, so no special settings are required.

Main screen

 When the loop tuner (krkrlt.exe) is started, the following screen is displayed (The following screen is where the file was actually read)
lt_main_window.png

Reduced waveform display
 Here you can see the waveform of the whole sound, reduced. The horizontal red line indicates a link, and the vertical green line indicates a label.
 Click to display the area in the waveform display area. Double-click to start playback from that position.
 Creating a reduced waveform takes time, so everything may not be displayed immediately after loading a sound or changing the width of the window. (Since the reduced waveform is created in the background, Will be displayed).
Timeline label display part
 Here, a timeline is displayed so you can see where the waveform is located and how long after the beginning of the sound.
 Label information is also displayed here. The inverted triangle mark represents the label.
 You can select a label by clicking the label.
 Double-click the label to edit the label name.
Waveform display section
 This shows the sound waveform.
 You can zoom in and out of the waveform with [View | Zoom In] or [View | Zoom Out].
 When you click on the waveform, a flashing vertical bar appears at that location (this is called the caret). [Play | Play from current position] allows you to start playback from this location. In [View | Zoom In] or [View | Zoom Out], the image is enlarged or reduced around this position.
 Double-click on the waveform to start playback from that position.
 If the waveform does not fit on the screen, a scroll bar appears at the bottom.
 The vertical dotted line displayed in the waveform display area indicates the position of the label or link. This vertical dotted line can be dragged with the mouse and its position can be adjusted.
Link display part
 Here you will find information about the link.
 The link is displayed as an arrow, meaning that when the playback position reaches the original part of the arrow, the link moves to the part beyond the arrow.
 Dotted links represent conditional links.
 Click the link to select the link.
 Double-click the link to display the link editing screen.
[File (F) | Open (O) ...] (lt_open.png) Shortcut key: Ctrl + O
 Open the target sound file. If changes have been made to a file that is already open, a dialog box appears asking if you want to save the changes.
[File (F) | Save (S)] (lt_save.png) Shortcut key: Ctrl + S
 Save the current contents to a file. The file name will be the PCM format file name with .sli appended to the end (for example, se001.wav for se001.wav.sli).
[File (F) | End (X)]
 Exit the loop tuner. If changes have been made to a file that is already open, a dialog box appears asking if you want to save the changes.
[Edit (V) | Undo (U)](lt_undo.png) Shortcut key: Ctrl + Z
 Cancel the last edit and return to the previous state.
[Edit (V) | Redo (R)](lt_redo.png)
 Apply the changes undone with "Undo" again.
[Edit (V) | Delete (D)](lt_delete.png) Shortcut key: Del
 Delete the currently selected item.
[Edit (V) | Create new link (J)](lt_new_link.png)
 Create a new link. The link is created with the location you clicked last as the destination of the link and the location you clicked twice before as the source of the link. Therefore, if you want to create a link, first click on the place where the link originates, then click on the place where the link will go, and finally select this menu.
[Edit (V) | Create new label (J)](lt_new_label.png)
 Create a new label.
[Edit (V) | Edit link (T) ...](lt_edit_link.png)
 Opens a screen for adjusting the currently selected link.
[Edit (V) | Create label at playback position (A)](lt_new_label_on_play.png) Shortcut key: A or S
 Creates a label at the current playback position. Labels can be created by key punch. If it is difficult to hit only the A key repeatedly, you can also use the S key. It is easy to press the A key and the S key alternately.
[Edit (V) | Delete all labels (Q)](lt_clear_all_labels.png) Shortcut key: Ctrl + Q
 Delete all labels.
[View (V) | Zoom In (I)](lt_zoom_in.png) Shortcut key: I
 Enlarge the waveform.
[View (V) | Zoom out (O)](lt_zoom_out.png) Shortcut key: O
 Reduce the waveform.
[View (V) | Follow screen to playback position (F)](lt_follow.png) Shortcut key: F
 Follow the screen to the playback position.
[View (V) | Display Toolbar (T)]
 Shows / hides the toolbar.
[Display (V) | Display flag (G)](lt_edit_flags.png)
 Displays the flag edit bar.
 The flag edit bar has 16 edit fields, each representing a flag. You can also change the value. By double-clicking in the edit field, you can set the value to 1 if the number is 0, or to 1 if it is 0 (toggle).
 Click the [C] button at the left end to reset all flags to 0.
[Display (V) | Display reduced waveform (E)]
 Switches display / hide of the reduced waveform.
[View (V) | Status bar display (S)]
 Shows / hides the status bar.
[Play (P) | Stop (Q)](lt_stop.png) Shortcut key: Q
 Stop playback.
[Play (P) | Play from the beginning (P)](lt_play_from_first.png) Shortcut key: P
 Start playing from the beginning of the sound.
[Play (P) | Play from current position (C)](lt_play_from_current.png) Shortcut key: Space
 Start playing the sound from the caret position.
[Play (P) | Play without link (G)](lt_ignore_links.png) Shortcut key: G
 When this item is checked (it is pressed down), all links will be ignored and played. If the playback position reaches the link's original position, it will not follow the link.
[Help (H) | Help (H)]
 Displays help.
[Help (H) | About Loop Tuner (A)]
 Displays the copyright information and version information of the loop tuner.

Edit link screen

You can display this screen by selecting [Edit | Edit Link] or by double-clicking the link.
Refer to the menu that appears when you right-click a waveform for the shortcut keys that are valid on this screen.

lt_link_tuner.png

Link conditions
 At the top is where you edit the link conditions.
 You can make this link a conditional link by checking the Conditional checkbox. The conditions are specified in the right part.
 The condition can be specified in the following format.

 [A] flag is [B][condition]

 For [A], specify the flag number (0 to 15) to be compared.
 For [B], specify a numeric value (0-9999) to be compared.
 For [condition], specify the condition. There are six conditions: when is the same, when is not, when is greater, when is greater than, when is less than, and when is less.

 The value to be compared can be from 0 to 9999, but it is better to use 0 or 1 unless it is a special use. (The flag edit field displayed in "Display flag" of the main screen you can easily enter 0 or 1 by double-clicking.)
Waveform display section
 In the waveform display area, you can check the waveform immediately before the link and the waveform immediately after the link. The blue waveform on the left is the waveform before linking, and the red waveform on the right is the waveform after linking. The waveforms that appear faint are the waveform after linking before linking and the waveform before linking after linking, respectively, and are superimposed.
 The waveform can be adjusted by dragging with the mouse. You can also make adjustments using the link adjustment buttons located at the bottom of the waveform display area.
Link adjustment button
 There are 12 link adjustment buttons, the left six adjust the position before the link, and the right six adjust the position after the link.
To previous crossing point (lt_left_cross_point.png)
Find the previous crossing point (the point where the waveform intersects the -Inf line) and go there.
20 steps forward (lt_20_step_left.png)
Move 20 steps forward. One step is 16 samples if the magnification is 1/16 and 1 sample if the magnification is 1/1, depending on the waveform magnification.
One step forward (lt_1_step_left.png)
Move one step forward.
Next one step (lt_1_step_right.png)
Move one step forward.
Next 20 steps (lt_20_step_right.png)
Move to the next 20 steps.
To the next crossing point (lt_right_cross_point.png)
Find the next crossing point (the point where the waveform intersects the -Inf line) and go there.
Change magnification button (lt_zoom_in.pnglt_zoom_out.png)
 Change the magnification. The scale factor is displayed as / 1 next to this button. / 1 represents 1/1 (1 pixel is 1 sample). / 16 means 1/16 (1 pixel is 16 samples).
Make links smooth(lt_smooth.png)
 Makes links smooth. When this button is checked (indicated as pressed down), the loop tuner and Kirikiri will mix and play back the waveform before linking and the waveform after linking with a short crossfade (50 ms). As a result, crack noises such as "small" and "small" generated when the waveforms before and after the link do not match well can be reduced.
Stop playback (lt_stop.png)
 Stop playback.
Playback (lt_play_before.png)
 Play near the link. You can play from 0.5 seconds ago, 1 second ago, 2 seconds ago, 3 seconds ago, 5 seconds ago.
 Clicking the play button marks it (it changes color). After that, if you press the space key, it will behave the same as clicking the button (it will be played before the link for the same time as the last button you clicked).
[OK] button
 Commit the changes and close the window.
Cancel button
 Discard your changes and close the window.

Note
 If the link source of the unconditional link and one or more conditional links are in the same position, the conditional link condition test takes precedence.
 If there are multiple unconditional links, it is undefined which link is used.
 If there are multiple condition links, the test order will be undefined.
 "Same position" in this case means exactly the same position. If even one sample is misaligned, it is not considered the same position.

Label expression

 Labels can have special handling of flags as they pass through the label by setting a special format "expression".
 If you write an "expression" in the label, you must start the label name with a ':' (colon).
 The expression consists of a flag for the operation target, "operator (operator)" that indicates what kind of processing is performed on the target, and "operand > "(Some operators have no operands).
 The flag to be operated is specified by enclosing the flag number (0 to 15) with '[' ']' (brackets). If the operand is a numeric value, describe the numeric value as it is, and if you want to specify another flag, specify it by enclosing the flag number (0 to 15) with '[' ']' (brackets).
 There are the following types of operators.
=
Assigns the value of the operand to the value of the flag
+=
Adds the value of the operand to the value of the flag
-=
Subtract the value of the operand from the value of the flag
++
Increment the value of the flag by one
--
Decrease flag value by one
 In either case, the value range of the flag is always 0-9999. If it is less than 0, it is corrected to 0, and if it is more than 9999, it is corrected to 9999.

Example:
:[0]=1 Assign 1 to the value of flag 0
:[1]=[0] Substitute the value of flag 0 for the value of flag 1
:[1]+=3 Add 3 to the value of the first flag
:[0]++ Increment the value of the first flag by one

Note
 If multiple labels are in the same position, the order of execution is undefined.

Hints and Tips

Adjust links
 If the adjustment is not good at the joint of the PCM by the link, crack noise will occur. You can use the "Smooth Link" (Smooth Link) function to reduce this crack noise, but we recommend that you make adjustments without a smooth link first.

 In the case of music generated in an electronic environment such as sound source + sequencer, in most cases, you can find a point that almost matches before and after the link as shown in the figure below.
lt_link_tuner_wave_match.png

 In addition, there are some points that make noise less noticeable, even if it is inevitable.
  • The position of the seam is less noticeable if the loop seam is immediately before the snare or cymbal drum. It is convenient just before high sounds, pops, etc.
  • The noise is less noticeable at the seam at the crossing point
Controlling song progression with conditional links
 Controlling the progression of the song that reflects the progress and scene of the game, such as starting from the intro, looping, exiting the loop under a certain condition, and entering another loop depending on the progress of the game, etc., operating conditional links and flags Can be achieved by
 However, of course, the link works only at the position specified in advance by the loop tuner. Even if you change the link condition, the playback position will not change unless the link position is reached.
 If the problem is that you can't get out of the loop until the end of the loop is reached, for example, if the loop is long, you need to devise a song composition so that you can get out of the loop in the middle of the loop.
 For example:

lt_complex_loop.png
 At the start of playback, flag 0 is 0. The "intro" is played, and the "loop" part is played repeatedly.
 Here, when the game progresses and the flag 0 becomes 1, you will exit this "loop" at the time of (1) or (2).
 If you exit the loop in (1), it will be played back to (3) via "(1) → (3) transition", and the "rest" will be played.
 Also, if you exit the loop in (2), after going through (2) → (3) transition, you will jump to (3) by the link, and the "rest" will be played.

 I think various applications are possible.