10 January 2010, 04:25 | #1 | ||
Wipe-Out Enthusiast
Join Date: Nov 2005
Location: .
Age: 43
Posts: 2,545
|
Blitz Basic - MED problems
Ok, i've decided to take the plunge and try to pull myself away from AMOS. ("at last" some of you cry)
But.... i've thrown myself into a mire straight away. One of the reasons i want to learn BB is because of a particular project i want to work on. The only part of this project so-far completed is the Music, loveling crafted in OctamedSoundstudio, using the MMD1 format, and with some Octamed-Only commands in there. I know, it's bad to start a project with the music, but i figure, if i cant use my music with Blitz, i frankly dont want to use the language at all! Now, i would have been quite content had the in-built MED commands worked, but they play things at the wrong speed. It ignores the BPM speed set in the MEDs and it doesnt much like the SPD setting either. (Even then, you need to use multiple calls of 'PlayMED' within one interupt, which to me, sounds totally wrong) Given that the BB2 manual says to call 'PlayMED' as such: Quote:
Quote:
Now i must ask, can anyone assist with some BB2 knowledge? At the moment, i see possible solutions as; - Butcher my MEDs to 'sort of' work with the crappy playback commands already there (i've tried this, and the results are not very pleasing) - Find a set of replacement BB commands which have working MED functions. (i've been searching Aminet for may hours but maybe someone has a suggestion, or better still, one they have used themselves?) - Compile the OctamedSS playback source (proplayer.a - http://aminet.net/package/dev/src/OcSS_src ) in asm, and call it from Blitz code... This option seems the most likely to achieve the right result, but throws a lot of difficulties for me. Basically, i havent much idea where/how to start doing this! I would i guess have to feed it the filename in an address register, perhaps butchering some of the playback code from the source above? I assume then i just 'load' the code into an address (i assume blitz has data banks like AMOS?) and JMP/JSR to it as required? How would i call other functions like telling it to start at a different pattern to 0 ? Do i need to know the offsets into the compiled code, by disassembling it? (e.g. putting the code at A1 and using JSR $100(a1) to call a different function $100 bytes into it?) Is this method still going to need me to call the compiled equivalent of PlayMED on every CIA interupt? If so, that's another address/function i'll need to find in my compiled code. Any thoughts / tips / help / general guidance on getting this going would be most appreciated. edit: perhaps this: http://aminet.net/package/dev/basic/BlitzASMInclud might help create some working/decent MED commands for BB2 Last edited by Hungry Horace; 10 January 2010 at 05:16. |
||
11 January 2010, 15:08 | #2 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Do you know if BB2 can use AmigaOS shared libraries? If so then the medplayer.library is the easiest way to get your song to play properly.
|
11 January 2010, 18:02 | #3 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Blitz can use shared libraries and I am certain med.library will be supported somewhere.. Check aminet I guess
|
11 January 2010, 18:46 | #4 | |
Wipe-Out Enthusiast
Join Date: Nov 2005
Location: .
Age: 43
Posts: 2,545
|
Quote:
it is, but it's vblank timed not CIA timed, which is why i would like to build new commands based on the sources above I've looked on aminet and theres no alternative. I'm currently using a good Protracker set of commands i got from there but it's not ideal. |
|
11 January 2010, 18:55 | #5 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Just in case you didn't know this, the medplayer.library is just what it says, a MED player. It abstracts the replay routine and does proper allocation of audio channels, timers and interrupts for you, and will play all MED songs correctly. It's far less work than assembling the replay routine and implementing new commands for use within BB.
|
11 January 2010, 19:35 | #6 | |
Wipe-Out Enthusiast
Join Date: Nov 2005
Location: .
Age: 43
Posts: 2,545
|
Quote:
either creating something to call medplayer.lib "properly" or using the 'standalone' player in the OSS source via new commands seems to be the only option. There arent any alternatives (that i've found, and i've done a lot of searching) which do it. |
|
11 January 2010, 20:19 | #7 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
It's possible that the BB MED commands use an old version of the replay routine which simply didn't include timer automization. You don't have to call the replay routine 50 or 60 time a second during vertical blanks. You can call it at any rate you want using any means.
I looked a bit at the part about implementing new BB commands but it was very convoluted. The help file in the BB2 package I found mentions some commands that look to be used for accessing shared libraries, but they tell nothing and just reference other help files and manuals. Do you know if these manuals are freely downloadable somewhere? |
11 January 2010, 21:31 | #8 | |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
Quote:
|
|
11 January 2010, 21:34 | #9 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
@Leffman
http://utilitybase.com/ref/?action=L...oup=BlitzBasic is kind of old but should tell you what to use. |
11 January 2010, 21:36 | #10 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Maybe I am missing something but BB supports in-line asm so why not just use that to open the external medplayer.library and play the songs?
|
11 January 2010, 21:56 | #11 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Blitz will fully support the medplayer.library if the FD us converted (I tghink blitzlibman is used).
|
11 January 2010, 22:03 | #12 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Libraries are independent of any Compiler/language, so BB does "support" the medplayer library, it's just a matter of calling its functions with the correct parameters, i.e. a standard include file for the medplayer lib is enough.
|
11 January 2010, 22:42 | #13 | |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Quote:
Samurai Crow, thanks, it seems to be the exact same help file I already have. If you can do inline asm in BB2 then here's a simple stand alone example of how you can use the medplayer.library: Code:
OpenLibrary = -552 CloseLibrary = -414 GetPlayer = -30 FreePlayer = -36 PlayModule = -42 StopPlayer = -54 LoadModule = -72 UnloadModule = -78 ;------------------------------------------------------------------------------- section code_p ; Start the song and wait for the user to click the mouse ; before we exit Start bsr Play bne .exit .waitpress btst #6, $bfe001 bne .waitpress .waitrelease btst #6, $bfe001 beq .waitrelease bsr Stop moveq #0, d0 .exit rts Play ; Open the library move.l 4.w, a6 lea library(pc), a1 moveq #0, d0 jsr OpenLibrary(a6) tst.l d0 beq .error ; Call GetPlayer to initialize and pass 0 in D0 for audio ; output. Passing 1 will play MIDI over the serial move.l d0, a6 move.l d0, librarybase moveq #0, d0 jsr GetPlayer(a6) tst.l d0 bne .closelibrary ; Load the song from disk lea module(pc), a0 jsr LoadModule(a6) move.l d0, modulepointer beq .freeplayer ; Start the song move.l d0, a0 jsr PlayModule(a6) moveq #0, d0 rts .freeplayer jsr FreePlayer(a6) .closelibrary move.l a6, a1 move.l 4.w, a6 jsr CloseLibrary(a6) .error moveq #-1, d0 rts Stop ; Call StopPlayer, UnloadModule and FreePlayer in order move.l librarybase(pc), a6 jsr StopPlayer(a6) move.l modulepointer(pc), a0 jsr UnloadModule(a6) jsr FreePlayer(a6) move.l a6, a1 move.l 4.w, a6 jsr CloseLibrary(a6) rts modulepointer dc.l 0 librarybase dc.l 0 library dc.b "medplayer.library", 0 module dc.b "med.my_test_song", 0 |
|
12 January 2010, 01:28 | #14 |
Wipe-Out Enthusiast
Join Date: Nov 2005
Location: .
Age: 43
Posts: 2,545
|
Hi Leffman,
Many thanks for that code. I managed to get it playing my MED files, with correct tempos, after tweeking that code a lot to suit the BB2 assembler. So this is a big step forward! one bit of code in particular it didnt like (besides the labels, and constants that i had to remove) was Code:
move.l 4.w,a6 Code:
move.l 4,a6 My only problem now will be if i need to access any additional functions? In particular i' like to be able to start my MED file from a different point in the sequence, say at '14' instead of '0' , so it can play a different variation, or say i want to access the global volume control so that i can fade the MED volume to zero? looking over the library.doc file my understanding of the library constants still isnt great (i can just about see where you got the values from in libproto.h), but I cant see either of these referenced at all? anyway, this is still a big help so far, so thankyou for that |
12 January 2010, 08:43 | #15 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
@ HungryHorace - .w as in
Code:
move.l 4.w,a6 It's either not supported by the BB2 assembler or the BB2 assembler requires you to use a different syntax. |
12 January 2010, 18:34 | #16 | |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Quote:
Code:
SetModNum = -96 ; Play the second song move.l librarybase(pc), a6 moveq #1, d0 jsr SetModNum(a6) rts The library offsets are the hexadecimal values listed right after each function name in the libproto.h file, e.g. offset -$2A for PlayModule. |
|
12 January 2010, 20:48 | #17 | |
Wipe-Out Enthusiast
Join Date: Nov 2005
Location: .
Age: 43
Posts: 2,545
|
Quote:
The multimodule might be enough (although you have to duplicate any blocks used in both sub-songs, which seems a bit of waste of space to me) - could the overall volume be altered by tapping the h/w directly? |
|
12 January 2010, 21:06 | #18 | |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
Quote:
Volume can be set per audio channel with the AUDxVOL registers. Replace x with the audio channel number (0, 1, 2 or 3) Valid values are 0 - 64. For reference the volume regs are: $dff0a8 $dff0b8 $dff0c8 $dff0d8 |
|
12 January 2010, 21:55 | #19 |
Wipe-Out Enthusiast
Join Date: Nov 2005
Location: .
Age: 43
Posts: 2,545
|
thanks pmc
firstly, i just noticed there is a 'volume' control in BB2 to do exactly that anyway, but that produces the same effect as directly accessing the h/w registers. The result is not good! I think the two are 'fighting' for the volumem, overriding each other - whilst i am telling it to go lower, the med.library player is setting it at its "wanted" volume and a horrible crackling sound is produced. |
12 January 2010, 22:09 | #20 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
Hmmm, that's annoying.
Where do you set volume? Have you tried doing something like this: call player set your volume call player set your volume So that (hopefully) your volume settings continually override what the player code just set. Bear in mind that I know nothing about BB2 and how you handle interrupt calls with it (which is I presume how the player code is called) so I might be talking total rubbish! Alternatively I wonder if there's any mileage in picking apart the med player and trying to work out where / how volume is set and then altering the code to suit your needs? As another suggestion, do you have to use med? You might have more options by using ProTracker for example as you'd have more choice of player code... Just throwing around ideas - no guarantees any of these are good or elegant solutions! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
AMOS or Blitz Basic 2 | Dreedo | Coders. General | 42 | 23 September 2014 21:48 |
Blitz basic 2 Help | Havie | Coders. Blitz Basic | 30 | 08 September 2013 09:15 |
blitz basic | petza | request.Apps | 11 | 08 April 2007 01:49 |
Blitz Basic 2 anyone? | jobro | request.Apps | 12 | 28 November 2005 18:15 |
Blitz Basic 2 | LaundroMat | Retrogaming General Discussion | 5 | 24 July 2001 08:10 |
|
|