nesdev.com
http://forums.nesdev.com/

Pently: a flexible, space-efficient NES music player
http://forums.nesdev.com/viewtopic.php?f=6&t=13589
Page 4 of 5

Author:  tepples [ Fri Jul 01, 2016 2:03 pm ]
Post subject:  Re: Pently music player is coming

dougeff wrote:
I find volume control to be one of the most important effects. Every channel, preferred.

Would four levels (1/4, 1/2, 3/4, full) be enough for this? Or is there a musical use case for more?

Quote:
Also, down the road, ot would be nice if we had a library of instruments, so every musician doesn't have to reinvent the wheel (or piano-ish volume envelope, for example).

I agree. Compose with pentlyas and let's build one.

Author:  dougeff [ Fri Jul 01, 2016 2:17 pm ]
Post subject:  Re: Pently music player is coming

How would that correspond to Famitracker's volume column? Something like...

D-F = 100%
9-c = 75%
5-8 = 50%
1-4 = 25%
0 = off

??

Author:  tepples [ Fri Jul 01, 2016 2:29 pm ]
Post subject:  Re: Pently music player is coming

That'd be about right: 4, 8, B, F.

The thing motivating the limit of 4 levels is that the NES CPU is slow at multiplying, and I don't want to introduce a bunch of 256-entry lookup tables to make it fast. So I plan to make an engineering tradeoff among control, ROM space, and CPU time.

Author:  dougeff [ Fri Jul 01, 2016 2:36 pm ]
Post subject:  Re: Pently music player is coming

Oh good. I feel good about the new, improved Pently. It seems to be filling in the short-comings of other music drivers. I may try to use it in the future, for game development.

I'm not sure how sound effects will work with it, but I really haven't tried yet. It sounds like you've gotten it to work with your own games, so I guess I'll probably figure that out too, when I get to that point.

Edit...

Quote:
NES CPU is slow at multiplying....compromise


Agreed.

Author:  tepples [ Fri Jul 01, 2016 2:46 pm ]
Post subject:  Re: Pently music player is coming

Sound effects work in almost exactly the same way as the drum track. Each drum is made of one or two sound effects. Or did you mean you haven't had a chance to understand how drums work either?

Author:  dougeff [ Fri Jul 01, 2016 2:53 pm ]
Post subject:  Re: Pently music player is coming

Sorry, I mean game-generated sound events. Collect a coin = ding.

Author:  tepples [ Fri Jul 01, 2016 3:07 pm ]
Post subject:  Re: Pently music player is coming

In musicseq.pently, make sfx ding on pulse. Then do this from the game code:
Code:
  lda #PE_ding
  jsr pently_start_sound

(The "PE_" part stands for "Pently effect".)

Thread safety caution: Some people like to run the music engine in the NMI handler to avoid audible consequence of slowdown. If you call pently_update_sound in the NMI handler, don't also call Pently API functions in the main thread; that'll cause undefined behavior if it interrupts itself. Instead, add commands to a list in RAM that the NMI handler processes.

Author:  Hamtaro126 [ Sat Jul 02, 2016 4:09 am ]
Post subject:  Re: Pently music player is coming

Is there a any possibility of ''Go to Track #n'' and ''Go to Previously Buffered Track'' effects for pently?

Makes things easier for full-on jingle effects, such as the ''Time Running Out'' jingle in mario games!

Author:  tepples [ Sat Jul 02, 2016 4:48 am ]
Post subject:  Re: Pently music player is coming

From the manual's description of pentlyconfig.inc:
If PENTLY_USE_ROW_CALLBACK is enabled, the main program must .export two callback functions: pently_row_callback and pently_dalsegno_callback. These are called before each row is processed and when a dalSegno or fine command is processed, respectively. They can be useful for synchronizing animations to music. For pently_dalsegno_callback, carry is clear at the end of a track or set if looping.

So turn it on and use pently_dalsegno_callback to know when to restart the music.

Do you want more details?

Author:  Hamtaro126 [ Sat Jul 02, 2016 6:26 am ]
Post subject:  Re: Pently music player is coming

tepples wrote:
Do you want more details?


Yes... That would help a lot if more details are added

Author:  tepples [ Sat Jul 02, 2016 6:30 am ]
Post subject:  Re: Pently music player is coming

  1. When you start the song for a level, save the song number of the song for the level in a variable.
  2. When you play a temporary song that ends, such as a fanfare that time is about to expire, do not save its song number.
  3. In pentlyconfig.inc, change PENTLY_USE_ROW_CALLBACK = 0 to PENTLY_USE_ROW_CALLBACK = 1.
  4. Create a subroutine in your main program called pently_row_callback that does nothing (that is, immediately executes the rts instruction). This is required because the same configuration option enables both pently_dalsegno_callback and pently_row_callback
  5. Create a subroutine in your main program called pently_dalsegno_callback, and .export this subroutine. If called while carry is clear, this means that the temporary song that ends, such as a fanfare that time is about to expire, has ended. In this case, it should load the song number from variable in step 1, and if it's a valid song number, call pently_play_music.

If this is not enough, then as I wrote in this post:
Please give us more details on your requests for "more details". What parts of the post did you understand, and what parts of the post did you not understand? If you are unable to express what parts of the posts you did and did not understand, I will have to break up the explanation into smaller posts, as if this were a chat room instead of a forum, and ask you whether you understood each part.


Or did you want me to actually write the code for you?

Author:  Hamtaro126 [ Sat Jul 02, 2016 4:20 pm ]
Post subject:  Re: Pently music player is coming

So from what i gathered... Follow how the NES Mario engines originally does things:

-Make and use a subroutine for Main to handle the two music buffers, One for main songs, and one for event (effect) songs
-Then store the songs in one of two buffers, Restore back to the main song when the event (effect) song finishes

I think it is good enough from here if so...

Author:  tepples [ Mon Nov 21, 2016 10:52 am ]
Post subject:  Re: Pently music player is coming

Many free software licenses require the license to be reproduced in full in all copies, such as the MIT License (Expat variant) currently used for Pently. This is why the NES Classic Edition's front end includes several pages of "Legal Notices". But then it can afford to do so because it has half a gigabyte of NAND flash for the Linux kernel, emulator, and game ROMs. NES games distributed on Game Paks, on the other hand, are in the tens to hundreds of kilobytes and may not have enough space to store a viewer for the entire software license in the binary. So the MIT License (Expat variant) alone might not be the best choice, as it requires the notice to be reproduced in all copies. This has already caused problems for use of Pently in ROM hacks.

There are a few other non-copyleft licenses. Before Pently moved to Git, I had been using a variant of the GNU All-Permissive License changed to limit the credit requirement to source code:

Quote:
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved in all source code copies. This file is offered as-is, without any warranty.


My project templates and the game RHDE: Furniture Fight still use this license.

If we find it useful to go with a better-known license, I was considering switching to the license of zlib, which similarly requires the full notice only in source code and encourages but does not require credit in object code. This license is also used by the Allegro 5 library, and it carries forth the spirit of the "giftware" license used by Allegro 4.

As the only contributor so far, I have the right to make this license change unilaterally, but I'm opening this to others' input because I'm nice. So comment here or in bug 10.

Author:  tepples [ Wed Jan 11, 2017 3:54 pm ]
Post subject:  Re: Pently music player is coming

Channel volume control is checked into GitHub.

Author:  tepples [ Thu Jun 01, 2017 7:05 am ]
Post subject:  Re: Pently music player is coming

I've proposed five enhancements to how arpeggios can be entered into a score.


Thoughts?

Page 4 of 5 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/