English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 05 January 2021, 23:01   #1
Bren McGuire
Registered User
 
Bren McGuire's Avatar
 
Join Date: Nov 2019
Location: Croydon
Posts: 580
Load Protracker file in Blitz?

Is there any free code out there to be able to load a protracker file in Blitz?
I'm not looking for player code necessarily, but something that can take a protracker file as input, load its samples in memory and access its sequence, but not necessarilty play it.
I guess as such it should not have any assembler in it to do this unless it is impossible to do without assembler.

I'm trying to make some analytics.
Bren McGuire is offline  
Old 06 January 2021, 01:37   #2
Coagulus
Gets there in the end...
 
Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 862
If you're not looking to play it you could load it into a bank?

http://eab.abime.net/showthread.php?t=61648
Coagulus is offline  
Old 06 January 2021, 15:41   #3
Bren McGuire
Registered User
 
Bren McGuire's Avatar
 
Join Date: Nov 2019
Location: Croydon
Posts: 580
That seems a bit crazy, is there really no protracker player source?
I know exactly what data I want to get out of the file for my analysis, I don't need to plonk the whole module in RAM and then read memory addresses.
Bren McGuire is offline  
Old 06 January 2021, 18:48   #4
Coagulus
Gets there in the end...
 
Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 862
What are you trying to access? The Protracker format is well documented and if loaded into a bank is accessible and editable.

If you use the PHXplayer lib the module can be played from the bank too.
Coagulus is offline  
Old 06 January 2021, 18:58   #5
Bren McGuire
Registered User
 
Bren McGuire's Avatar
 
Join Date: Nov 2019
Location: Croydon
Posts: 580
Hold on a second, will have to say I am a total Blitz noob first to not get hammered :P

Now, I was reading again through the Blitz manual and I see Blitz already has a way to load MODs and MEDs into your program.
I also see you can load a sample from disk, and create sound data, but I cannot see how you would access the data loaded by LoadModule or LoadMedModule directly.

Would Bank allow me to do what I want? I want to:

- read module name and display it
- read sample name and display it
- create sound object from sample data loaded by module
- play that sound object

?



Quote:
Originally Posted by Coagulus View Post
What are you trying to access? The Protracker format is well documented and if loaded into a bank is accessible and editable.
Bren McGuire is offline  
Old 06 January 2021, 19:35   #6
Coagulus
Gets there in the end...
 
Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 862
Haha no hammering here. I'm a noob when it comes to many things Amiga. I had fun trying to access modules. At one point I was loading them into a bank , saving them to RAM and then loading them using the player code!

I don't think the built in commands give you much access to the mod data itself. At least the PHXplayer loads into banks and plays from there meaning you can peek and poke whatever you want and still play it.

1 and 2 definitely. 3 not so easily as I don't think you can play a sound from a memory location in Blitz using Blitz commands normally.

A botch could be to add a pattern with the sample you want to play triggered and then jump to that pattern when the mod is played... not an elegant solution and there may well be a better answer.
Coagulus is offline  
Old 06 January 2021, 20:41   #7
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
To play a sound, once you know where in memory it's stored, you could create a dummy sound object and either copy the data into the object, or modify the object's pointer to point at the data. It's unlikely the sound data will be in the Blitz internal sound object format, so you might need to do some basic decoding and manually set the other parameters in the sound object structure. You can see the sound object structure here: http://www.amigacoding.com/index.php...ct_types#sound and include the definition in your code by adding the bb2objtypes.res resident file to the compiler options.
Daedalus is offline  
Old 06 January 2021, 21:03   #8
Coagulus
Gets there in the end...
 
Coagulus's Avatar
 
Join Date: Sep 2005
Location: Wales
Posts: 862
You see, that's a much more proper way of doing it.
Coagulus is offline  
Old 07 January 2021, 00:44   #9
Bren McGuire
Registered User
 
Bren McGuire's Avatar
 
Join Date: Nov 2019
Location: Croydon
Posts: 580
So how to know where the sample data will be at?
Would loading the MOD file as a Bank as Coagulus mentioned work? The Protracker MOD file format is well documented and if I can put the MOD file at a certain memory location, offsetting from there should be kinda trivial.

Can this be done with LoadModule or LoadMedModule at all?
Do I need to include PHX's routine at all if all I want is to load the sample data in memory and then play it off using regular Blitz sound procedures?

As for the sound data itself, wouldn't using the SoundData procedure be good for this? The manual says "altering IFF sounds is OK" but doesn't detail how.
Oh, seems like DecodeSound might be what I need to use, actually.

Thanks both for your valuable help (and Dastardly for the Blitz wiki on Amigacoding, been reading all day )

Quote:
Originally Posted by Daedalus View Post
To play a sound, once you know where in memory it's stored, you could create a dummy sound object and either copy the data into the object, or modify the object's pointer to point at the data. It's unlikely the sound data will be in the Blitz internal sound object format, so you might need to do some basic decoding and manually set the other parameters in the sound object structure. You can see the sound object structure here: http://www.amigacoding.com/index.php...ct_types#sound and include the definition in your code by adding the bb2objtypes.res resident file to the compiler options.
Bren McGuire is offline  
Old 07 January 2021, 17:29   #10
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Quote:
Originally Posted by Bren McGuire View Post
So how to know where the sample data will be at?
Would loading the MOD file as a Bank as Coagulus mentioned work? The Protracker MOD file format is well documented and if I can put the MOD file at a certain memory location, offsetting from there should be kinda trivial.
Yeah, that's probably the way to do it. Just be doubly sure your offsets are valid, because once you go into things at that level, it's very easy to bring the whole OS down with a bad calculation or assumption

Quote:
Can this be done with LoadModule or LoadMedModule at all?
Do I need to include PHX's routine at all if all I want is to load the sample data in memory and then play it off using regular Blitz sound procedures?
If you're just loading the file and interpreting it yourself, there's no need to load it with a dedicated library. Alternatively, if you do use e.g. LoadModule, you can get the location of the Blitz object (which then contains the module address) with the Addr Module(0) function.

Quote:
As for the sound data itself, wouldn't using the SoundData procedure be good for this? The manual says "altering IFF sounds is OK" but doesn't detail how.
Yes, that can be done if you know where the audio data is, but that alone is simply changing the bytes of an already existing sound object. You need to do a bit more to change the size of the object, for example.
Quote:
Oh, seems like DecodeSound might be what I need to use, actually.
Quote:
Thanks both for your valuable help (and Dastardly for the Blitz wiki on Amigacoding, been reading all day )
You're welcome (I did much of the Blitz section on AmigaCoding too )
Daedalus is offline  
Old 08 January 2021, 15:32   #11
Bren McGuire
Registered User
 
Bren McGuire's Avatar
 
Join Date: Nov 2019
Location: Croydon
Posts: 580
Mate I don't know what I was smoking, I meant to write DAEDALUS, I must have been reading another thread at the same type and confused users. Sorry! And thank you for such an amazing resource


Quote:
Originally Posted by Daedalus View Post
You're welcome (I did much of the Blitz section on AmigaCoding too )
Bren McGuire is offline  
Old 08 January 2021, 15:57   #12
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Well this is wild, I'm looking to do something similar here, will be reading up on this thread. Thanks to all.
Amiga1992 is offline  
Old 12 January 2021, 22:41   #13
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by Daedalus View Post
Yes, that can be done if you know where the audio data is, but that alone is simply changing the bytes of an already existing sound object. You need to do a bit more to change the size of the object, for example.
OK looking into this, what does DecodeSound actually do? BEcause if you pinch the data from a Protracker file, the samples are stored as absolutely raw sound data, so it's not actually an iff. The descriptors are actually separated, else where in the format.

Document says "allows to include sounds inside code", but I am assuming this is if you incbin an iff file? So DecodeSound would be useless in this scenario, and SoundData is exactly what you'd want to use.

Please correct me if I am wrong.
Amiga1992 is offline  
Old 13 January 2021, 10:30   #14
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Ah, that's a good point actually (I haven't tried it myself) - DecodeSound probably does expect an IFF header on the sound data that the Protracker file doesn't contain. Apologies!

Some additional manual interpretation of the ProTracker format is needed then, so you can get the necessary details from the file and manually copy the sound data over to a new sound object.
Daedalus is offline  
Old 13 January 2021, 17:38   #15
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
I just realized that this could easily land into a memory nightmare because DecodeSound would make a copy of the sample data into a new sound object, so you'd need a lot more RAM than the module takes just to be able to do this.

Unless there's a way to make the sound objects just reference the sound data via a pointer instead of having the actual sound data in them...
Amiga1992 is offline  
Old 13 January 2021, 17:42   #16
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
You can create a pointer to a sound type and point it to the memory address. Getting the syntax right will be the tricky bit...
E-Penguin is offline  
Old 13 January 2021, 19:24   #17
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by E-Penguin View Post
You can create a pointer to a sound type and point it to the memory address. Getting the syntax right will be the tricky bit...
I guess we will have to test and find out....
Amiga1992 is offline  
Old 14 January 2021, 02:28   #18
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Quote:
Originally Posted by Akira View Post
Unless there's a way to make the sound objects just reference the sound data via a pointer instead of having the actual sound data in them...
Unfortunately you can’t specify that something must be INCBINed into chip memory, so the data must be copied.
idrougge is offline  
Old 14 January 2021, 09:42   #19
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
I guess you could test the pointer address to see if it's under $20 0000, then it must be in chip and thus avoid having to do a copy.
E-Penguin is offline  
Old 14 January 2021, 13:52   #20
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
AmiBlitz3 includes the "Chip" compiler directive for locating chunks of the executable in chip RAM, but I've never tried using it. in theory it would allow you to Incbin data that will be always loaded into chip RAM. It can only be used once though, so you would put it at the end of the actual program, and put all your Incbin chunks after that.

Under Blitz 2 it would always end up in fast RAM if there's fast RAM available. That's a nice suggestion, to check if it's in chip RAM first and then do a copy if needed.
Daedalus is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Protracker file format, number of samples phx Coders. General 21 02 August 2019 22:45
Blitz Basic 2 and Protracker mods Radertified Coders. Blitz Basic 3 13 September 2018 22:55
Can't Create File error using Protracker 2.3d ViLXDRYAD support.Apps 5 09 December 2016 15:44
Protracker 3.xx Load Sample womagrid support.Apps 3 27 May 2016 06:28
Load Cubase made sample in protracker Brick Nash support.Other 4 26 May 2016 18:28

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 23:03.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10374 seconds with 14 queries