nesbox / TIC-80

TIC-80 is a fantasy computer for making, playing and sharing tiny games.
https://tic80.com
MIT License
5k stars 483 forks source link

implement Effects column in the Music Editor #261

Closed nesbox closed 4 years ago

nesbox commented 7 years ago

0x Mute delay, x = frames before mute 1x Speed, sets the speed when x is between 0 - F 2x Note delay, delay before the current row is triggered, x = frames to wait 3x Automatic portamento, slides to new notes x = speed (0 to disable) 4x Vibrato effect, x = speed 5x Jump to pattern x 6x Fine pitch, x = offset (8 is default) examples

C-5 02 F 02 - Plays C-5 with instrument 02 at volume F for exactly 2 frames before muting. C-5 02 F 18 - Sets track speed to "8" on this line C-5 02 F 22 - Plays C-5 with instrument 02 at volume F after waiting 2 frames. Does not mute previous note C-5 02 F 32 - 32 turns on portamento (note sliding) so previous pitch should slide to this note, and it will slide to any new notes until you put "30." "speed" starts at 0 and goes to a max of F (fast slides) C-5 02 F 42 - Plays vibrato at x speed. This is usually not used on a note, but on a blank space after a note. C-5 02 F 52 - Jumps to pattern 2 after playing this note. C-5 02 F 62 - Plays that note but detuned by -6. since "8" is the middle, 9 is +1, 10 is +2, etc

darkhog commented 7 years ago

Also suggested effects: Portamento up Portamento down Fine portamento up/down - same as portamento up/down, except speed is divided by 4 Volume slide up/down, so you can do fadein/outs on certain sustained instruments.

Slide to note is useful, but sometimes you don't need it & manual portamento works better.

Decidetto commented 7 years ago

A way to put conditions on the 5x effect would be essential for space efficiency. It could be used to for example make it play patterns 0, then (1, 2) 2 times, then continue with patterns 3, 4, 5, repeat (6, 7) 3 times and finally return to pattern 0 to loop fully. Much retro music is built on repetition, so needing to have copies of the same patterns in your "playlist" will make you run out of space quickly.

StinkerB06 commented 6 years ago

This is cool! But there's no way to input them into the editor.

kostik1337 commented 6 years ago

I'd really like to see arpegio effect (similar to 0xy effect in protracker/fasttracker), but as I can see, there's only one digit for effect parameter.

@Decidetto: 5x effect is probably designed to add intros to songs, e.g. play first two patterns once and loop the rest of composition infinitely. For repetition, I can suggest adding two more effects, say A0 and Bx, where A0 sets loop start point and Bx sets loop end point with repetitions count

StinkerB06 commented 4 years ago

Also, 00 should correspond with infinite sound length to prevent breaking all current music tracks.

nesbox commented 4 years ago

I decided to use 3 columns for the tracker command: command [0-7] 3bits, parameter1 [0-F] 4bits, parameter2 [0-F] 4bits. The existing Volume column is deprecated and will be automatically converted to the Volume Output command on a cart loading. Here is an existing command list with the small description:

The checked commands are implemented and can be tested on the music-commands-wip branch. Here is the latest build https://builds.tic80.com/music-commands-wip.

StinkerB06 commented 4 years ago

@nesbox To prevent breaking carts that pack binary data in the music pattern memory, the "do nothing" command should accept note volume as one of the parameters.

nesbox commented 4 years ago

@StinkerB06 do you know these carts with binary data packing?

StinkerB06 commented 4 years ago

I don't know any. But if there is a cart that does have packed data (using memory poke and sync(), or by injecting into the cartridge file), then the volume-column conversion would mess it up.

On Thu, Dec 12, 2019, 8:16 AM Vadim Grigoruk notifications@github.com wrote:

@StinkerB06 https://github.com/StinkerB06 do you know these carts with binary data packing?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nesbox/TIC-80/issues/261?email_source=notifications&email_token=AHFK2N5BTRRQXURVBFVSZULQYJPVDA5CNFSM4DWVTNMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGXF45I#issuecomment-565075573, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHFK2NYOPYDHX4OHX3NDCFDQYJPVDANCNFSM4DWVTNMA .

nesbox commented 4 years ago

So, the Music Commands branch is merged to master and here is an explanation of how the commands work:

*** MUSIC COMMANDS***

(please don't forget, all the command values are hex)

[M xy] - changes the master volume for left(x)/right(y) channels.
example:
M00 turns off the volume.
MF0 turns on the only left channel.
M88 turns on both channels on half of the max volume.

[C xy] - produces chords by doing a simple arpeggio that extends the base note with the given semitones.
example:
C37 plays a minor chord: 0, 3, 7, 0, 3, 7, 0, 3, 7, ...
C47 plays a major chord: 0, 4, 7, 0, 4, 7, 0, 4, 7, ...
C0C plays 0, 0, C, 0, 0, C, 0, 0, C, ...
CC0 plays 0, C, 0, C, 0, C, ...
CCC plays 0, C, C, 0, C, C, 0, C, C, ...

[J xy] - jumps to frame (x) and beat (y), row = beat*4

[S xx] - performs a pitch bend that stops when it reaches a current note with the provided number of ticks (xx).
example:
C-4 00 ---
F-4 00 S08
--- -- ---
C-4 00 S10
This will result in a pitch bend that starts with C-4, bends to F-4 in 8 ticks, and then bends back to C-4 in 16 ticks.

[P xx] - changes pitch up or down with a given offset. 128 (P80) is the default value.
example:
P82 - plays a note but detuned by 0x82-0x80=+2.
P62 - plays a note but detuned by 0x62-0x80=-30.

[V xy] - vibrates pitch with given period (x) and depth (y).
example:
V43 - vibrates pitch with period 4 and depth 3.

[D xx] - delays triggering a note with the given number of ticks (xx).
example:
D10 - plays a note after 16 ticks, you can also mute the note this way.

Also, it would be great if someone with a musical background could test it and give some feedback before release, you can download it here https://builds.tic80.com/master/2019.12.16

Thank you all for the help with the issue!

StinkerB06 commented 4 years ago

Oh my, this is awesome! About the binary data-breaking thing: Change the type 0x0D chunk to 0x0F.

borbware commented 4 years ago

The feature mentioned in this comment didn't work for me:

The existing Volume column is deprecated and will be automatically converted to the Volume Output command on a cart loading.

In my project (.lua cart made with 0.70.6 pro), the volumes were not converted; all notes were left in maximum volume.

EDIT: seems to work for .tic carts but not for .lua carts.

nesbox commented 4 years ago

Yes, conversion works with .tic carts only, because cart loading can handle different chunk types and I marked CHUNK_PATTERNS as deprecated and, unfortunately, I can't do the same for text carts. So, to convert .lua cart