Ok its pretty easy to calculate the lenght of streams and stuff in ms and display different counters and what not for the lenght of a stream ie differet progress indicators.
Music such as xm, mod, s3m, mid ect are totally different stories. I know i can no trust the FMUSIC_IsFinished to reliably tell me that the music has finished playing. since most music will jump back to some certain order and loop itself. I really want to show the Play time of the module, and whatnot. Currently I get the number of orders adn then get the pattern lenghts for each order and come up with a value, which i am assuming this to be the 'total play time' in bytes. Question is, do I need to keep track of the bytes played by getting the pattern lenghth of the current order and adding this to some global variable? Also is ther a way for me to tell how much time the module takes to play, since lenghts and whatnot are returned in bytes.
Calculating modules length is a really hard task. Winamp doesn’t play them internaly but it scan all row of all pattern for the effect collumn. In fact, effect influes on the duration of the module (vibrato, retriger …). This method can do the job for almost all modules but there are some with some special tricks with wich we can’t do anything. I have done a DLL (it was for vb users) wich return the length of the module, the code is not mine but from James Chapman ( http://www.vuplayer.com ). Interested, just mail me or reply here
Note : i found that this code is more efficient/accurate that Steve Snakes (in_mod.dll coder).
I just finished playing around with the MIDAS system u spoke about. I found (a) it didn’t like playing all my it files, some xm files, (b) it also did not sound HALF as good as FMOD. (c) it ate more CPU and memory then FMOD. (d) the api calls were very hard to read in code, MIDASInit, MIDASclose, ect I would suggest that they seperate MIDAS with a _, or something this makes reading code using it much more easier.
On the plus side the source code was avilable, however the vb example included within was very poor and failed to load correctly for me. On the plus side it would support what I wanted to do. However it is not near what FMOD is, I shall wait for Brett to release the extra stuff for FMUSIC.
Well i’am sure there must be a way without having to use additional 3rd party software to calculate the simple ‘time’ of a module. It does not have to be superaccurate.
Currently when i load the module, i loop through all the orders getting the pattern lenght of each order to come up with the total bytes to play.
Now using either the speed or bpm i should be able to come up with a ‘rough’ estimate as to the time required to play that module.
Uhmm… as said before, calculating the running time of a module is a very hard question.
However it is possible if u have the patterns with at least the effect column and the effect parameter.
The effects you must consider are:
- Speed Tempo/BPM
- Skip Pattern
- Jump to pattern
Things will become easy with this consideration: BPM (Beat Per Minute) tells you how large is the buffer for a tick. If BPM is 125, you have a frequency of (BPM*2)/5=50 Hz (trust me, it is so!)
Now it is possible to have the duration of every tick: 1/50=0,02 seconds –> 20 ms
Now you know that a tick is 20 ms.
You know also that in a row there are (speed) ticks. Take speed=6 as an example: 20 ms per tick * 6 ticks = 120 ms -> a row takes 120 ms of time !
A pattern of 64 rows will take 120 ms * 64 rows = 7680 ms, 7 seconds and 680 ms
If there is a speed/bpm change, don’t worry: you can calculate separately the time for every row and then sum it in a general variable.
How can I calculate the BPM rate from a playing STREAM every third seconds, like in Adion’s Example Application (D/L-Link: http://www.geocities.com/TelevisionCity … ection.zip)?!
Which informations do I need to collect and how do I must calc. them to get the no° of BPM’s…?
Thanks in advance….
<font size=-1>[ This Message was edited by: UnKn0wN on 2002-03-14 09:03 ]</font>
- UnKn0wN answered 17 years ago
I think your formula is incorrect.
If 125 BPM would mean 20ms per tick, that would mean 200ms per 10 ticks or 100 ticks per 2 seconds or 50beats/second
In a minute you would have 50*60beats/second which is a LOT more then 125.
The correct formula is 60000/BPM which will give you the time for one beat.
So 60000/125 = 480ms.
You can see this is correct because 120beats/minute is 2 beats/second or 1 beat/0.5seconds.
Hey man that formula works beauitfuly however I need to get any changes to the speed speed at the given row. I am using FMUSIC_GetPatternLength to aquire the number of rows, and I am assuming that the track can only adjust the speed 1x per row. Thus some way of GetSpeedAtRow( pattern, row) is needed i’am assuming? If I use the default speed for any songs that don’t do any change to the speed i’am dead on according to Mod4Win, however if any speed changes occur it throws my calculations off, slightly for small changes, large if the speed change are radical.
So as I walk through each pattern aquireing its lenght in rows, i need a way to find out if the speed changes, can fmod do this or must I suffer with inaccuracy?
Well even an api that would give the time of the module in question.
Umm, the way i see it now, once u start a music u have absoultly no way of knowning when it should end this don’t seem right to me, I mean why even support them if u can’t know when to seamless intergrate it with another module and whatnot, anyhow…
Bret have ue ever seen mod4win program? It was a really kick but mod,xm,s3m player for its time. My favorite part is that u could hit the ‘effects’ button see in real time as the effects were in play i’d love to work this type of display for mods into my player, though to be quite honest is beyound my understanding of the fmod system atm. Here is a snapshot of mod4win effects in action.
Just thought I would say that reading the modules time using that formula does seem to work for most xm, it, s3m mods. It might be alittle off but at least it gives me some idea where to end.
Basicall I check if the playtime is greater then the modules calculated time its time to end. Works very well so far.
Is the above picture even feasable with the current information FMOD provides, or am i living in a dream world? I relize I would be looking at qutie a bit of work and whatnot but I don’t really wana start something like that only to find out that what I am targeting is not “yet” doable within the FMOD api.
The problem is that MODs can change speed during playback and can also loop indefinitely. I have some MODs that seem to hang WinAmp, but then it shows the length of the MOD as 746,000 minutes. This tell me that WinAmp calculates the length of the MOD by playing it internally as fast as possible and keeping track of the time. I don’t think that is possible using FMOD.
For now, your request is not feasable, as Brett said, a FMUSIC_NOTE could do the job. Midas Sound System use such structure for getting the note and in the members you have various informations about each note played. I recommand you to look in the source of Midas (well commented and very easy to understand).
Please login first to submit.