It is currently Tue Nov 21, 2017 10:39 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: FamiTone2 audio library
PostPosted: Mon Jan 13, 2014 8:37 am 
Offline

Joined: Sat Jan 23, 2010 11:41 pm
Posts: 1161
Download FamiTone2

The original FamiTone got a major update, with data formats change and player and tools code rewrite. The most important improvements are:

- Built-in FamiTracker text export support instead of the old TextExporter plug-in
- Faster code
- Smaller data size
- Tempo support
- Full NTSC/PAL support, with pitch and speed compensation


Top
 Profile  
 
PostPosted: Mon Jan 13, 2014 8:41 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3950
Dendy support too?

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Mon Jan 13, 2014 8:47 am 
Offline

Joined: Sat Jan 23, 2010 11:41 pm
Posts: 1161
No.


Top
 Profile  
 
PostPosted: Mon Jan 13, 2014 11:27 am 
Offline
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 932
Which assemblers are supported, which expansion audio is supported, and can any other formats be imported (such as MML or Csound)?

_________________
.


Top
 Profile  
 
PostPosted: Mon Jan 13, 2014 12:12 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19239
Location: NE Indiana, USA (NTSC)
zzo38 wrote:
Which assemblers are supported

From readme.txt:
Quote:
text2data outputs data in NESASM format by default, you can use -ca65 or -asm6 switches to get output for these assemblers.

From text2data.cpp:
Code:
#define OUT_NESASM   0
#define OUT_CA65   1
#define OUT_ASM6   2


Quote:
which expansion audio is supported

Doesn't look like any. From text2data.cpp:
Code:
#define MAX_PACKED_PATTERNS   (5*MAX_ORDER*MAX_SUB_SONGS)

That covers pulse, pulse, triangle, noise, and DPCM.

From nsf2data.cpp:
Code:
   if(nsf_data[0x7b])
   {
      printf("Expansion chips are not supported\n");
      free(nsf_data);
      return 1;
   }

Let me know which expansion audio is supported by any all-new-parts flash cartridge.

Quote:
and can any other formats be imported (such as MML or Csound)?

I see something that appears designed for sound effects in FamiTracker NSFs, but not much more.


Top
 Profile  
 
PostPosted: Mon Jan 13, 2014 2:06 pm 
Offline

Joined: Sat Jan 23, 2010 11:41 pm
Posts: 1161
Is it really necessary to quote random code pieces and make guesses when everything is clearly stated in the readme.txt, and is not changed since the original version? Please understand, I don't need any docs by myself, I spend quite some time and effort to write them for your convenience. Please read them.

line 14 of the readme.txt wrote:
Expansion sound chips are not supported.

'How to use the library' section wrote:
The main version of the FamiTone2 is written in NESASM. There are
versions for CA65 and ASM6 assemblers included in the package as well.


zzo38 wrote:
can any other formats be imported (such as MML or Csound)

No. It is clearly explained in the readme.txt which formats are supported and how it all works. It is possible to use other import sources, but you'll have to write your own converter, which is a good half of the whole thing.


Top
 Profile  
 
PostPosted: Tue Jan 14, 2014 7:04 am 
Offline

Joined: Thu Dec 12, 2013 4:00 pm
Posts: 40
I'm having trouble getting this to work with cc65. I have sound effects working fine, but I can't get music to work at all.

This line of code is what *SHOULD* play the music:
Code:
if(controllerInput&PAD_START) music_play(music_test);


Here is the function definition for music_play (I DID modify it slightly):
Code:
_music_play:
   stx <PTR
   tax
   ldy <PTR
   jmp FamiToneMusicPlay


Is there something I'm missing?

_________________
For some reason, I seem to have a lot of luck with NES-related stuff.

There are two kinds of people in this world: those who are convinced there are two kinds of people in this world, and those who aren't. - Unknown


Top
 Profile  
 
PostPosted: Tue Jan 14, 2014 8:11 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5825
Location: Canada
If music_play is a fastcall function with one parameter, that parameter is in A. What are you doing with X?


Top
 Profile  
 
PostPosted: Tue Jan 14, 2014 8:55 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2981
Location: Tampere, Finland
The confusion maybe stems from the fact that in FamiTone1, FamiToneMusicStart took a 16-bit parameter (pointer to the music data), whereas in FamiTone2 FamiToneMusicPlay takes a single byte (sub song number).

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Tue Jan 14, 2014 1:36 pm 
Offline

Joined: Thu Dec 12, 2013 4:00 pm
Posts: 40
What exactly do I need to do in order to get a song to play with cc65?

_________________
For some reason, I seem to have a lot of luck with NES-related stuff.

There are two kinds of people in this world: those who are convinced there are two kinds of people in this world, and those who aren't. - Unknown


Top
 Profile  
 
PostPosted: Tue Jan 14, 2014 2:01 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5825
Location: Canada
Your _music_play function is broken, is what I was saying. I don't know where you got that from, as it does not appear to be part of FamiTone2.

The first question is whether it is declared correctly. If it takes one parameter in A, it should be declared like this:
Code:
extern void __fastcall__ music_play(unsigned char a);


The second problem is the contents of your _music_play routine. There is no useful value in X when it music_play is called from C, so storing it is counter-productive. Similarly, I don't know what you're doing with X or Y before you call FamiToneMusicPlay, which according to the readme takes a single parameter in A. Your _music_play should just look like this:
Code:
_music_play:
    jmp FamiToneMusicPlay


The rest of how to use it is in the readme, from what I can tell. Did you initialize it?


Top
 Profile  
 
PostPosted: Tue Jan 14, 2014 5:09 pm 
Offline
User avatar

Joined: Sat Feb 16, 2013 11:52 am
Posts: 223
Yes, thanks! I really didn't have any problems with version 1 but I appreciate the work that went in the text export support and better performance.

_________________
This is a block of text that can be added to posts you make. There is a 255 character limit.


Top
 Profile  
 
PostPosted: Wed Feb 05, 2014 7:11 am 
Offline
Formerly 43110
User avatar

Joined: Wed Feb 05, 2014 7:01 am
Posts: 313
Location: us-east
With these changes, Dendy can be supported by separating out tempo and pitch. Note the different input spec of A for FamiToneInit

Code:
--- famitone2.s   2014-02-03 11:15:22.886592429 -0500
+++ famitone2-edit.s   2014-02-03 11:17:29.781515804 -0500
@@ -209,7 +209,7 @@
 
 ;------------------------------------------------------------------------------
 ; reset APU, initialize FamiTone
-; in: A   0 for PAL, not 0 for NTSC
+; in: A   bit 7 is frame rate. bit 6 is pitch. 0 for PAL, 1 for NTSC
 ;     X,Y pointer to music data
 ;------------------------------------------------------------------------------
 
@@ -221,10 +221,7 @@
    sty <FT_TEMP_PTR_H
 
    .if(FT_PITCH_FIX)
-   tax                  ;set SZ flags for A
-   beq @pal
-   lda #64
-@pal:
+   and #192            ; mask out other bits
    .else
    .if(FT_PAL_SUPPORT)
    lda #0
@@ -374,8 +371,8 @@
    bne @set_channels
 
 
-   lda FT_PAL_ADJUST      ;read tempo for PAL or NTSC
-   beq @pal
+   bit FT_PAL_ADJUST      ;read tempo for PAL or NTSC
+   bpl @pal
    iny
    iny
 @pal:
@@ -580,6 +577,7 @@
    adc FT_CH1_NOTE_OFF
    .if(FT_PITCH_FIX)
    ora FT_PAL_ADJUST
+   and #127            ;zero out bit 7
    .endif
    tax
    lda FT_CH1_PITCH_OFF
@@ -613,6 +611,7 @@
    adc FT_CH2_NOTE_OFF
    .if(FT_PITCH_FIX)
    ora FT_PAL_ADJUST
+   and #127            ;zero out bit 7
    .endif
    tax
    lda FT_CH2_PITCH_OFF
@@ -646,6 +645,7 @@
    adc FT_CH3_NOTE_OFF
    .if(FT_PITCH_FIX)
    ora FT_PAL_ADJUST
+   and #127            ;zero out bit 7
    .endif
    tax
    lda FT_CH3_PITCH_OFF
@@ -1010,8 +1010,8 @@
 
    .if(FT_PITCH_FIX)
 
-   lda FT_PAL_ADJUST      ;add 2 to the sound list pointer for PAL
-   bne @ntsc
+   bit FT_PAL_ADJUST      ;add 2 to the sound list pointer for PAL tempo
+   bmi @ntsc
    inx
    bne @no_inc1
    iny


Edit: typo


Last edited by JRoatch on Wed Feb 05, 2014 11:15 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Wed Feb 05, 2014 11:10 am 
Offline

Joined: Sun Apr 04, 2010 4:28 pm
Posts: 91
Tempo support makes this a huge improvement. Thank you Shiru!


Top
 Profile  
 
PostPosted: Fri Feb 07, 2014 12:17 pm 
Offline

Joined: Sun Apr 04, 2010 4:28 pm
Posts: 91
I translated the FamiTone2 library to the assembler format used by Ophis. Because Ophis does not support conditional compilation (ifdef, etc.), I simply left all features enabled.

Total library size is 1632 bytes, including 259 bytes of data. Song data for my project is 20% smaller than the previous version of FamiTone.


Attachments:
famitone2ophis.asm [27.16 KiB]
Downloaded 103 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group