Playing Music (Able to play longer than 28 second files somehow?)

I am working on a game. Don't let that throw you, though, my question is pretty well contained within the bounds of this board.
Background:
In one of my previous projects, a turn-based strategy game, I had created a SoundPlayer class, which could load from files and produced Clip (I think) objects that could be played by my program. The problem was, it used up huge amounts of memory and I could only play at most one copy of each sound at a time (that is, I couldn't have, for example, two explosion sound effects going off and have them overlap) because of the way I had arranged things to keep them from loading too many times. The largest sound it could load was a 28 second wav file, and that didn't even work on all computers. Even on my computer, which had the overall best performance for running this program, sounds would sometimes not play, or rarely play over and over until they were told to play a second time. Most of this is probably my implementation, but it still wasn't working.
Questions:
How can I load large sounds, like music, either midi or mp3, or possibly some well compressed (small file-size) format that can contain the same type of data as a wav? How can I minimize memory use AND the amount of space used by the loaded-from files? How can I make it play more than one instance of the same sound at a time? How can I keep it so that things play the right number of times, not more, not less?
Additional Requirements:
I need to be able to stop the sounds, so I will probably need some sort of a handle to the object associated with it, and I may need to adjust its volume. Also, I may need to know when a sound finishes, either with a boolean or an event (or something like it) fired at the completion of the sound. It would help to know how far into a sound it has played, and in some cases it might be useful to be able to loop some number (or indefinitely) either over the whole sound or a part of it.
I know this is a lot, but sound is pretty necessary to make a good game.
Thanks in advance.

http://forum.java.sun.com/thread.jspa?forumID=513&threadID=450768

Similar Messages

  • HT2479 In iMovie is it possible for the music track to run longer than the video?

    In iMovie is it possible for the music track to run longer than the video? e.g. for there to be a short video clip playing during the intro to the song and then the song to continue to play in full once the video has finished?

    Yes. Just drag your music in from iTunes or wherever and the timeline will auto increase to the full length of the music track. Like this:

  • I upgraded my old mac to snow lepord and now when i try to play music in my i tunes it says "file can not be located" but it still lists all of my music

    I upgraded my old mac to snow lepord and now when i try to play music in my i tunes it says "file can not be located" but it still lists all of my music

    Use Spotlight Search (the magnifying glass on the top right-hand corner of your menu bar) to locate your music files. Then point iTunes to those files.

  • When i try to play music on itunes it says the original file cant be found. I have music on exyernal dive and it is working . How can i correct this

    When i try to play music on itunes it says the original file cant be found. I have music on exyernal dive and it is working . How can i correct this?

    See if you have most of the songs with 'Exclamation' symbol precede the name under your music library.
    If so, double click a song with ! mark on side, you will be given an option to locate the file where the song is held. Select "locate" and direct it to your External Drive folder / file where the song is and open it.
    iTunes then will give you the option to use this process to update all of your library.  OK that as this will fix all automatically instead of doing them one by one.

  • When my iPhone 4s plays music it pauses for about 4 seconds then plays

    I don't know what to do. I have only had my iPhone for about 2-3 months and suddenly this happens. It really annoys me when I am playing music on my headphones or out loud because it sounds like its broken. If there is a problem am I ensured by apple.

    Hello sound_freak,
    Thank you for the details of the issue you are experiencing when connecting your iPod to your your Wadia 170i dock.  I recommend reviewing the article below to further isolate and troubleshoot an issue like this (you can skip any steps you have already taken):
    Troubleshooting iPhone, iPad, and iPod touch accessories
    http://support.apple.com/kb/TS2634
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Music widget wont play music when touch 'play' button

    iPhone 6 with iOS8.1,
    I have tried reboot didn't work , only when I play music in music app, the music widget can work。

    not sure if this will help you guys, but it solved my issues. my itunes 9 and everything else that was negatively effected, is now working great.
    i read somewhere (sorry i dont have a link) about how to change your network settings. basically i opened op airport utility, found the time capsule (its both my router and HD), clicked manual setup, clicked wireless. once in this menu, i did two things. im not sure which one was the solution, but i did both since they fit my needs better.
    one thing i did was changed my "radio mode" from "802.11n compatible (802.11g/b compatible)" to "802.11n only (5GHz)". the second thing i did from the same wirless menu, was click the wireless options button, i changed multicast rate from 6 Mbps to 24 Mbps.
    both of the changes resulted in everything working fine. i can stream all my data to apple tv and play movie files without all the problems that i and many others are experiencing.
    like i said, im not sure if this will help you guys, but it helped me. so give it a shot if you dont see a diffference than revert back to whatever your original setting were. oh and please note, if your network is set to 802.11n ONLY, things that arent n compatible (like my iphone) wont see the network. so this solution my not work for everyone, but i have two wireless networks so its fine.
    good luck everyone

  • Tried to connect my ipod to TV through USB. Can play music but the TV cant detect video files

    Hi. I have an ipod nano 4th generation. I am obsessed with Doctor Who but unfortunately I do not have BBc America. I watch from itunes on my PC. I would like to sync the shows on the ipod and watch on TV. I am aware i can purchase apple's A/V cable, but i have found that my TV also has a USB port. I plugged in my ipod and four menus came up, "video" "pictures" "music" and "settings". I can play music but the Tv wont find the video files on the ipod.
    Thanks!!!!

    iTunes Match on your computer can give you the same higher quality files. 
    Run iTunes on your computer.  Show your music library by Song in list view.  Add the columns for Bit Rate, Kind, and iCloud Status to the list view.
    Any song that is shown as Matched for iCloud Status, that is NOT already 256 kbps (or higher) for Bit Rate can be downloaded from iCloud at 256 kbps AAC.  For example, if you have an old album from a music CD that you ripped years ago at 128 kbps MP3, and it is "matched" by iTunes Match, you can replace the lower quality files you have now with 256 kbps Match AAC audio file (which is shown for Kind).
    To do so, select the song, or a set of songs, on the library list.  Press Delete.  Confirm you want to delete the song (but do NOT check the box to delete song from iCloud) and choose to move song file to the Trash.  The songs remain on your iTunes library list, with a "cloud" download button next to the song name. 
    Click that button to download the song from iCloud.  Because the song is Matched, you get the replacement as a 256 kbps AAC audio file, instead of the original 128 kbps MP3 file (or whatever lower quality format it was before).
    You can go through your iTunes music library, and replace lower quality Matched songs with higher quality versions, thanks to iTunes Match.

  • Ipod mini works, but wont play music or eratically plays static

    I have rebooted the software and gotten the latest updates on the ipod. menu works fine, but when it comes to playing music, there is either no sound or sporatic static, like its having a hard time reading the digital music. thoughts anyone?
    sony vaio   Windows 2000  

    Have you been through these?
    The Five Rs.

  • Music plays - Music doesn't play ?

    iTunes 10 library on external HD, wireless, OS 10.6.4,
    I have AirTunes working and listen to music on my external speakers. Sometimes the music moves to the next song in a list and plays but no sound. If I double click the song it starts over and plays with sound. I might get 3-4 tunes and it will do it again.
    Any ideas on what's happening and how to fix it so my music can play ALL the time?
    I've done restarts of the modem, Airports and computer. I've repaired preferences and turned off Bluetooth but I rarely get more than 3-4 songs to play before all goes silent yet the song advances as if playing. Never ending issue.
    Thanks - Roger

    Question. When I plug in my headphones, the music plays. But when I try to play it without headphones, it doesn't really play. Sometimes it doesn't play at all. Other times, it won't play the first 20 seconds and then only plays five seconds. The songs are downloaded not streaming thru google play. How do I fix this? I've only had the phone 1 month.

  • Ipod wont play music when songs played stays at 0 no sound

    no music will play on ipod

    Hey this has happened to me a couple of times to but
    my works if you leave it alone for awhile ( maybe i
    just hit it in the right spot). However before this
    happened for 3 weeks or so my ipod would randomely
    stop playing if it is on hold. i think this is
    related to a malfunction in teh feature were if you
    take out the headpohones it stops playing. Did your
    wife experience similar problems?
    Recently my ipod has a near inaudible volume. it's up
    all the way, hte max volume is up all way, and when i
    adjust max volume the volume comes back but as soon
    as i exit out of the adjustment it becomes quiet
    again.
    My ipod is working now just from fiddlings and
    leaving it alone (temperature effect it?)
    If your wife experienced any similar problems let me
    know so i can send it in before it progresses to be
    worse.
    It works now but for how long? thanks
    No.. leaving it alone doesn't seem to help. It's really kind of weird, it's like everything works except playback via headphones. I can actually play songs that are store on the ipod when connected to iTunes (i.e., on my computer). Just that headphones don't seem to work.
    Sigh. Thanks for the post though.
    Jacen

  • Why does my IPad Mini randomly play music while i play games

    Random music plays while I play games. Does this happen to anyone else?

    Sorry there are some typos above, but you should be able to figure out what I'm asking. Let me know if you have tha same problem, know how to fix it, or know if apple is aware of the problem and is adressing it in a future update.

  • My computer wont play music but it plays the start up and shut down noise. why?

    well the subject name is self explanatory and sums it up in one sentence but in depth.....
    i was listening to music one day and the sound started to cut out and get static-y almost. after a couple of seconds of that the sound stoped playing all together but the song itself was still playing through. at first i thought it was just my itunes so i tried to listen to something on youtube when that didnt work i tried adjusting the volume settings, switching it from headphones (which didnt work either) and back to speakers, restarting the computer, googling, calling both my neighbor and boyfriend. still couldnt figure it out; still couldnt get it to work. frustrated, i stoped using my computer for a week. one day i decided to play a game on it and the start up noise came on while powering up so i went to see if my music was working again. still nothing. i began playing a game later on in the day and the sounds of the game worked every so often but still no music! im tired of not having my music so please help!!!!!

     Download & Save the latest Audio driver from your support page.Go into Control Panel,Programs & Features- Uninstall IDT software.Restart the laptop. After Windows loads, install IDT audio using the downloaded file.
    http://h10025.www1.hp.com/ewfrf/wc/softwareCategory?os=4063&lc=en&cc=us&dlc=en&sw_lang=&product=5218...
    ******Clicking the Thumbs-Up button is a way to say -Thanks!.******
    **Click Accept as Solution on a Reply that solves your issue to help others**

  • Is it normal for iPad Air 2 to vibrate when playing music, watching video, playing game, or anything related to the sound?

    I just bought my iPad Air 2 and it is vibrating when do anything related to sound. I want to know is it normal or just me? should i bring it back to Apple Store?

    A number of people have reported having vibration problems. One thread below. I'd bring it back for a different one or a refund if you're dissatisfied.
    Re: iPad Air 2 sound vibration

  • Not able to read other than text files

    Hi,
    I am trying to read a set files in a folder, but i am able to read only test files all other file format cannot be read. word document is not read correctly!
    I use fileInputstream object and get the bytes of the file length and set the charset to "UTF-8". the output is like a junk data.
    I feel i need to set the exact charcterset, but donot no how, can any body help me out.
    i tried character.unicodeblock.of this is not returning the exact uincode( may be i am wrong)
    Thanks in advance.

    Don't read binary files as though they were text.
    Also if you are just copying files, you shouldn't even bother to read text files as text, unless you want to go beyond copying and, say, change the encoding.
    [http://java.sun.com/docs/books/tutorial/essential/io/index.html]

  • Ac3 file tiny bit longer than m2v file!

    Hi
    Anyone had this?
    At some point compressor started making the files different lengths.
    this causes problems authoring in DVDSP.
    It never used to do it!
    anyone know why.
    BB

    How much is it out by? It's in the nature of compressed audio that things are in certain sized packets, and so you could see a slight difference in length, but that shouldn't affect sync. Also, if you append several m2v/ac3 sets end to end the slight overshoot or undershoot is dealt with, you don't get a progressingly longer overshoot.

Maybe you are looking for

  • Configuring resolution on Samsung SyncMaster 932BW monitor

    I just bought a new Samsung SyncMaster 932BW monitor and can't figure out how to configure the resolution on it. It's widescreen, and supposed to be set at 1400 X 900, but the only options I have in the Displays System Preferences are 640 X 480, 800

  • Changing Material Type using BAPI

    Hi All, I am trying to change a material. I able to change many fields of the material  except 'Material Type' using BAPI_MATERIAL_SAVEDATA.  Did any one used BAPI_MATERIAL_SAVEDATA or any other BAPIs to change the material type of a material? I do n

  • How To Delete a Row From a TableView !!!!

    Hi, Does any know how to delete a row from a table view model. I have a TableViewModel being displayed, when the user select the particular row and click delete i want that particular row to be deleted. Any Suggestions How. Thanks, Emmanuel.

  • Ejb in web dynpro for java

    Hi,     i have a scenario in which I need to insert as well as retrive data from a dictionary table on SAP DB. can anyone provide me step by step procedure or  code? Plz dont give the links of bonus application,car rental application and phonebook ap

  • Can't send any mail since Safari 3.2 update

    I have updated Safari to v.3.2 and been unable to send any mail ever since. I use Mail 3.5. I've tried everything, checked all the settings, still doesn't work. It's Ok to receive mail. When I try to send anything I get the message "e-mail address re