android
  #1  
Old 07-28-2010, 03:11 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 537
Default Song playback tool, WaveCrave V2.0

WaveCrave is a library developers can take and integrate into there apps and will be able to play a full length song while only taking up little ram.




in version 2.0 there are 2 examples included proving that you can play a full length song while doing something else.




any comments, feedback, or concerns feel free to post.
(if anyone can find the right settings to use in the convert that would be a big help)


download: download the code in attachment below and download the songs from the following link and put the songs in WaveCrave\songs\
Songs


NOTE: this app will not run properly in the adk because it uses wav.time()

NOTE:The guitar game shows what this app will run like when the the parts are all differnt lenghts while the mario shows what will happen when the song parts are all the same lenght
Attached Files
File Type: zip WaveCrave 2.0.zip (418.5 KB, 56 views)

Last edited by jbob182; 09-16-2012 at 07:04 PM.
Reply With Quote

 
  #2  
Old 07-31-2010, 09:08 PM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 635
Default

I thought wave.time was only used to get the playing time (in milliseconds) of a loaded wave file.
I copyd this out of an app that was posted when this forum had just started It might help to explain what it does..
Code:
sound1 = wav.load("mus1.wav");
Play_length = wav.time(sound1);
text.draw(10,10,"Play length sec. = "..Play_length/1000)
Reply With Quote
  #3  
Old 08-01-2010, 10:46 AM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 537
Default

it is used to get the lenght of the song. which is exactly what i want. the thing about the player is it's max it 10mb of ram and the way i do it it never exedds more that 7mb or so and you can adjust it to take up as much or as little as you want all you need to do is repeat a function a couple of more times

i am trying to make this as easy as possible for people to use. right now i am working on a timing mechanism. i have tried using framerate for a clock and am still working with that idea.

note that since i can never exceed 10mb unless we can get an addon like there is for ds homebrew so we can use resources that never pile up on the ram the songplay will have some really short pauses here and there but it isnt that bad

i wont be able to work on it for a few days though.
Reply With Quote
  #4  
Old 08-05-2010, 04:19 AM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,063
Default

Quote:
Originally Posted by jbob182 View Post
i am simplifiying the code right now which also eliminated some bugs. after i finish my timing will be much simplair
-------------------------------------------------------------------------------------------------------------------------
just finished simplifying and is much smaller(the code) and the bugs are gone

the only last thing is a clock. I cant just us os.clock() because it uses millisecons and as you should know the framerate is only about 30fps which wont make the clock constant. also it is too precise i need something that will use seconds and i need to get wav.time working and so far i have had no sucess besides getting the value 0 i will experiment some more with the function
------------------------------------------------------------------------------------------------------------------------
i have it all working execpt for wav.time() and when i run it i get an error saying Lua Run Error : attempt to call method 'play' (a nil value)
That's all good and well, but why are you posting this in the dev thread for TapHero? It's Gruffler's dev thread for that application, not for a sound splitting app. I would suggest that you make another thread for your tool app so this thread won't be cluttered with irrelevant posts, (irrelevant to Gruffler's actual progress with the app such as you saying you will resume work but mean your tool, not the app the thread is about)
[Thread split into its own]
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote
  #5  
Old 08-05-2010, 05:05 AM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 635
Default

Quote:
Originally Posted by jbob182 View Post
the only last thing is a clock. I cant just us os.clock() because it uses millisecons and as you should know the framerate is only about 30fps which wont make the clock constant. also it is too precise i need something that will use seconds and i need to get wav.time working and so far i have had no sucess besides getting the value 0 i will experiment some more with the function
------------------------------------------------------------------------------------------------------------------------
i have it all working execpt for wav.time()
It seems that wav.time() only works on the player, on the simulator it returns 0 but on the player it returns the playing time in milliseconds.

I don't get the problem with the clock, does it have to be 30 fps? If you really want seconds you can use os.time(), it returns seconds passed from 1970 or something, both on player and simulator.
Quote:
Originally Posted by jbob182 View Post
and when i run it i get an error saying Lua Run Error : attempt to call method 'play' (a nil value)
I guess you're using "play" for something else in the code as well.
Reply With Quote
  #6  
Old 08-05-2010, 10:21 AM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 537
Default

Quote:
That's all good and well, but why are you posting this in the dev thread for TapHero? It's Gruffler's dev thread for that application, not for a sound splitting app. I would suggest that you make another thread for your tool app so this thread won't be cluttered with irrelevant posts, (irrelevant to Gruffler's actual progress with the app such as you saying you will resume work but mean your tool, not the app the thread is about)
[Thread split into its own]
yes i was planning on starting a thread soon but thanks for splitting it.

Quote:
I don't get the problem with the clock, does it have to be 30 fps? If you really want seconds you can use os.time(), it returns seconds passed from 1970 or something, both on player and simulator.
i have the clock up and running and i am using os.clock and i do some math and I have seconds so all is well



Quote:
I guess you're using "play" for something else in the code as well.
actually if you consider song2: play() something else then i guess so but thanks for the info on the wav.time that means once i put that in all i have to do if fix the one last bug
Reply With Quote
  #7  
Old 08-05-2010, 10:26 AM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 635
Default

Quote:
Originally Posted by jbob182 View Post
actually if you consider song2: play() something else then i guess so
No I mean like, if you have a variable or a picture or something else called "play", but on a second thought, it wouldn't be "nil" then..

I notice there is a space between "song2:" and "play", that would explain the error?
Reply With Quote
  #8  
Old 08-05-2010, 02:26 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 537
Default

no i had to use a space while typing this because otherwise it would say


----------------------------------------------------------------------------
i have fixed the bug and the program works now i just have to experiment with wav.time()

Last edited by jbob182; 08-05-2010 at 09:49 PM.
Reply With Quote
  #9  
Old 08-05-2010, 03:57 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,063
Default

Quote:
Originally Posted by jbob182 View Post
no i had to use a space while typing this because otherwise it would say
Not if you placed it in code tags (without the spaces)
Code:
[ CODE][ /code]
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote
  #10  
Old 08-05-2010, 04:42 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 537
Default

ah thanks for the info and good new i have got wav.time to give me the lenght of the song in seconds and also os.clock to give me time in seconds all the parts are finished now

there is only 1 bug left that is i cant get the audio to play at all on the player. I am completly baffled i have even hooked up my code to Taphero but still cant get it too work right
Reply With Quote
  #11  
Old 08-05-2010, 05:04 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,063
Default

Quote:
Originally Posted by jbob182 View Post
ah thanks for the info and good new i have got wav.time to give me the lenght of the song in seconds and also os.clock to give me time in seconds all the parts are finished now

there is only 1 bug left that is i cant get the audio to play at all on the player. I am completly baffled i have even hooked up my code to Taphero but still cant get it too work right
You're sure the audio is the correct .wav? There are many variations and not all of them work. But the sim stupidly enough seem to be able to handle more kinds.
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote
  #12  
Old 08-05-2010, 05:27 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 537
Default

i have thought of that so i just did a plain songlay() right away no ifs and it worked fine right now i am resolving a problem where my app stuters but luckily my version with taphero still works
Reply With Quote
  #13  
Old 08-05-2010, 06:13 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,063
Default

Quote:
Originally Posted by jbob182 View Post
i have thought of that so i just did a plain songlay() right away no ifs and it worked fine right now i am resolving a problem where my app stuters but luckily my version with taphero still works
Sounds good. This might be revolutionary for how we handle sounds. Will it be able to handle to abort in the middle of a song, play another sound, and continue where it left off? Think that'd be possible to achieve with your code? Because I'm kind of in search for such a code, since we can't run multiple threads in our apps.
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote
  #14  
Old 08-05-2010, 06:34 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 537
Default

i think it is about time i explain what is really going on in my code. instead of a whole song I cut it into pieces in this case i use This Week I'v Been Mostly Playing Guitar by
Tommi Inkila which is a free song

Then i set how many sections.
Then it plays the first section, closes a dummy file i included that takes up like no space
then it gets the lenght of the part
afterwards it checks too see if my clock time matches with the part lenght
if so then it loads a new part, plays it and closes the previous. restarts the clock and repeats the checking


all the user has to do it chop a song in my case i do sections of 29 seconds then 14 then 29 ect which will only bring the ram up to about 7.2mb

also they have to add the locations of the file and specify how many parts

the only fallback is when it transits between parts there is a very short pause. It isnt that bad especially since this is the best we can do so far

as for your question i believe it is possible this is how it could be done

1. start playing song
2. complete a few parts
3. when you stop the part in saves the current lenght and how long it has been playing
4. play a diffenrt song
5. resume by loading the part#, length of part, and play time, and the song

ie:
song = "TWIBMPG"
part = 3
length = 29
songruntime = 20

i would need a function that could play a song from any time of it

Last edited by jbob182; 08-05-2010 at 06:40 PM.
Reply With Quote
  #15  
Old 08-05-2010, 06:42 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 537
Default

or you could just resume from a part it might set you back like 10 seconds but unless i have a function which i can play from anytime within the song it is all i can do

the function would look like

wav.play(time);



where time is what time in the song it starts
Reply With Quote
  #16  
Old 08-06-2010, 02:35 AM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,063
Default

I see. Well, it should be good enough for what I want to do. Problem is only if I can implement it with everything else that needs to go on in the background. The only thing that is a shame is that you have to manually chop the file. Sure it's no problem really, but it's time consuming and may affect accuracy.

And wouldn't stuttering be solved simply by having two pre-loaded file sections? You might have to cut down on the time for them but if it removes the stuttering it won't matter.
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote
  #17  
Old 08-06-2010, 10:13 AM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 537
Default

no that wasn't the problem i checked to make sure of that.

what was going on is i put in a wav.time() and as you know the adk returns 0 so it thought each part was 0 seconds long

as for chopping the files up i wanted to make an exe but i don't know C or C++ or C# i only know some basic and java along with lua

i might be able to create an code that virtualedub can read ie. reverse an avi file with a line or 3 of code.

i will check on that part along with any other options.

one other problem is that since i managed to get everything to give me time in seconds (ill explain how) which was VERY useful it had one downside : when a song is 29.855 seconds long it returns the length as 29 so a little bit of it gets chopped off what might work is i simply say +1 to the lenght value


the one last thing i have to fix is the audio still wont play on the player. I have an adk and an xfi version so the adk can run fine but the xf version doesnt

what i have done to test the bug to make sure it wasnt my audio files is a straight up
Code:
TWIBMPG part 1:play()
and it played. so i really cant figure out what is going on. The only logical answer would be that some of the functions i use dont exist in the player

i might relese an beta version soon if i cant solve this bug or ask one member to look at it




----------------------------------------------------------------------------------------------------------------------
as for how i managed to get os.clock and wav.time to give me the time in seconds this is how

Code:
songlength = wav.time(TWIGMPG part 1)
songlength2 = songlength*2

length = os.difftime(songlength, songlength2)

and there you go you have the time in seconds apparently os.difftime returns the value in seconds so it is differnt then just using the minus sign

as for the clock just do the some thing
Reply With Quote
  #18  
Old 08-06-2010, 10:22 AM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 537
Default

oh and as for the implanting i made very easy to intergrate i tell the person what goes where

as for doing stuff in the backround that was my first bug because i needed it in a while loop

but got it out of the while loop an had to rethink most of the code

then it didnt work

so i simplified the entire code immensely and ]then all the parts were alot easier to programm


i can intergrate it into anyone's code without a problem this is all I have to do note this is coming straight out of my code's comments

Code:
-- include this line in you main code: dofile("songs/song.lua");

--[[ you need this to be where you want to start playing a song: 
    playing = true
    part = 1
    song = "enter song name here"
    fullsong()
]]



--[[ this needs to be in the while loop of your code:
    while true do
        songcompare()
        time1 = os.clock()
    end 
]]
Reply With Quote
  #19  
Old 08-06-2010, 11:04 AM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 635
Default

Sounds like some nice work man Can't wait to see the whole code.

Quote:
Originally Posted by jbob182 View Post
also they have to add the locations of the file and specify how many parts
As habhome said it's too bad that the user has to chop the file, there are some free programs to do it, but an exe just for this app would be nice. (I can't help you with that though.. I don't know anything besides html and lua )
Specifying the amount of parts used however, can be avoided when you let the code just keep loading parts until there is a load error, like this:
Code:
part={}
x=0
parts=0

repeat
parts=parts+1
x=x+1
part[x]=wav.load("part" .. x .. ".wav")
until part[x]==nil

parts=parts-1
As for converting os.clock() and wave.time() to seconds, why not devide it by 1000 ?
Maybe you can even use the leftovers to keep the part playing until it's really ended;
Code:
songlength = wav.time(part.wav) -- in milliseconds
leftover = (songlength/1000) - math.floor(songlength/1000) --gives milliseconds after rounded seconds
songlength = math.floor(songlength/1000) --convert to seconds
Quote:
Originally Posted by jbob182 View Post
i would need a function that could play a song from any time of it
It's only possible to specify the playing time of a wave from the beginning in wav.play() so I guess we'll have to live with the replaying the whole part.
Reply With Quote
  #20  
Old 08-06-2010, 11:21 AM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 537
Default

ya i cant help either for the exe i might be able to create code in virtual dub to do it for you but that is the best i can do for now

as for the code about the loading to tell the truth i know very little about tables exept for animations and very basic stuff i wanted to just have the user specify the location but i needed a table to do so i will try and put that code into mine


i might need some expalining first


ok first line you create any emtey table called parts correct
seconds line and trhird line you declare variables
then you have the code repeats untill there is no more parts
next you have it keep on adding how many parts
then you keep on adding the tables section up by one each time along with the name of the part
then you load a part by ..... this is where i loose you it seams the x is the part name ie. part 1 where 1 is x
then part 2


is this what is going on?

as for the leftover idea i will try that BUT first i need to resolve the last bug which i am stumped if any1 would like like to take a look and try and fix it then just pm me with your email

when you pm an email you must use (at) and i think also (dot)

1.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 -5. The time now is 07:53 PM.