123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|282|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Can't play music...please help!

Tue, 16 Jun 2009, 19:52
Dither
Hello all,

I'm trying to accomplish a seemingly simple task: play a music file (MP3) in Blitz Basic. I'm using the original Blitz 2d published by Idigicon.

I've followed the coding examples in Krylar's book, and here's the weird part: Krylar's sample music (an OGG file) plays just fine, but when I use one of my own MP3s it refuses to play!

If I just load the music file and then play it, the program will run but it will be silent.

If I try to use channel commands like ChannelVolume, I will get an Illegal Memory Address telling me the sound does not exist, even though it is most definitely in the same folder as the program itself.

Any help would be greatly appreciated, as I'm pulling my hair out over this one!

Here's an example of something I've tried, for you to look at:



Thanks!
Tue, 16 Jun 2009, 21:17
JL235
I presume the only difference between that code and a working OGG version is replacing "Rain.mp3" with the name of an OGG file?

If so then I'd presume mp3s are unsupported in BB.
Wed, 17 Jun 2009, 01:27
Jayenkai
It could be that Olde BB relied on something in Windows that Microsoft have decided to remove over the years.
Not sure!
Might be best to use Ogg! blimey!

-=-=-
''Load, Next List!''
Wed, 17 Jun 2009, 02:08
Afr0
BlitzBasic includes it's own patented Pirate Protection System. It won't play pirated MP3s

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Wed, 17 Jun 2009, 07:51
Dither
JL235: I actually haven't tried this particular code snippet with an OGG file, but what you've said is true for other code I've used — it works with the OGG file, but not the MP3s (only change being the file loaded).

Jayenkai: I hope not but that does sound plausible. It won't even play MIDI files for me! Strangely, it plays WAV files, but only if they are short (i.e. it won't play a whole song in WAV format). Maybe I should buy BlitzPlus and see if that works.

Afr0: I know you're only joking but I'm still going to point out that the MP3 file is my own song, converted from a MIDI to a WAV to an MP3 many years ago. I've actually tried a bunch of different MP3s and none of them worked.

Thanks for the responses.
Wed, 17 Jun 2009, 07:58
Scherererer
I ran your program with a music file of my own (mp3), and it ran just fine. Here are some things you might want to try:

  • Verify that the file name is correct, and that it is in the right location -- if this doesn't work, try giving it a full file path just to test
  • Try a different mp3 file, the one you're trying to use may not be encoded properly
  • Update all of your music codecs; it might be that the music you're trying to play uses a more up-to-date encoding, or that the encoder blitz is trying to access cannot be found.
    This might be caused by:
  • If windows media player is uninstalled
  • You haven't updated your computer in 5 years

  • hope that helps!

    -=-=-
    YouTube Twitter
    Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus
    Wed, 17 Jun 2009, 19:44
    Dither
    Scherererer,
    Thanks for trying it out. May I ask which version of Blitz you are using? Responding to your suggestions:
  • Verified that file name is correct, and tried the full path. It still gives me an "Illegal Memory Address."
  • I tried several MP3s and all had the same problem.
  • I'm not really sure about how to update my codecs. However, Windows Media Player is still installed and is set for automatic updating of codecs. My computer is about 7 years old.

  • Wed, 17 Jun 2009, 20:14
    Scherererer
    I'm using Blitz 3D
    Wed, 17 Jun 2009, 20:30
    Dither
    Scherererer,

    I'm pretty well convinced the problem is with my computer. I tried downloading both the BlitzPlus and Blitz3d demos and that code didn't work on either one. In B+, the program ran but silent. In B3d, it returned "music not found."

    However, in all three versions of Blitz, the code works with a very small MP3 file (360KB, intended for looping). This plays just fine.

    Oh, and I tried converting my MP3s to OGGs and they still don't work. But I had a friend with Blitz3d try the code with one of my MP3 files and it worked for him.
    Wed, 17 Jun 2009, 22:13
    Stealth
    Try using lowercase for the whole file name.
    Wed, 17 Jun 2009, 22:29
    JL235
    Do a copy and paste of the MP3s name in explorer to BB. This is to ensure the case of all letters is the same and that your are using the correct name (i.e. no typos).

    But I'm thinking this is a codec problem.
    Thu, 18 Jun 2009, 04:57
    CodersRule
    Did you try PlayMusic instead of Playsound? Maybe PlaySound can only handle smaller mp3s.
    Thu, 18 Jun 2009, 05:19
    Jayenkai
    That's a good point, it might sort it.
    You can't loop it, though.. But then MP3's aren't really that good at looping anyway!

    It's still an odd issue, either way, and yet another point to add to the list of ever growing "Watch out, this might not work" issues..

    -=-=-
    ''Load, Next List!''
    Thu, 18 Jun 2009, 06:24
    Dither
    All lowercase for the file name: Gives the same result.

    PlayMusic instead of PlaySound: The program runs (i.e. no error messages) but it is silent.

    I think JL235 may be right. As mentioned above, I tried running the code on my machine using the Blitz3d demo, but got the same result I'm getting with Blitz2d ("sound does not exist"). Yet, the exact same code with the same MP3 file works on my friend's computer using Blitz3d. This tells me it's probably not a problem with the code itself, or the music file, or my version of Blitz. Must be something with this old computer.

    I don't know how to fix the problem, but at least I won't worry about the code itself. I'll just have to get a new machine some time soon.

    Thanks everyone for your suggestions!
    Thu, 18 Jun 2009, 06:46
    Jayenkai
    Out of interest, what system are you trying to run it on?

    -=-=-
    ''Load, Next List!''
    Thu, 18 Jun 2009, 07:53
    HoboBen
    Can someone compile to an .exe the very same code as posted for Dither, verify it works, send it to him/her and see if it plays on his/her system?

    That would show plainly if it is his Blitz version at fault or a problem with his/her computer.

    Conversely, maybe Dither can compile *his/her* program, and see if it runs on anyone else's system.

    -=-=-
    blog | work | code | more code
    Thu, 18 Jun 2009, 08:14
    Jayenkai
    I was going to suggest that, but if it's also happening with B3D and BPlus demos, then that'd suggest a more systemwide issue.
    Worth a shot, though, I suppose..

    Test.zip

    -=-=-
    ''Load, Next List!''
    Thu, 18 Jun 2009, 17:28
    Dither
    Thanks for the test, Jay. It worked for me. I laughed when I heard that MP3.

    Some info about my system:
    Intel Pentium 4 CPU 2.00GHz
    1.99GHz, 1.00 GB of RAM
    Windows XP Home Edition, Version 2002, Service Pack 2

    Update: I tried putting Jay's test.mp3 into my code in Blitz, and it worked there, too. Now I'm really confused!
    Thu, 18 Jun 2009, 18:31
    CodersRule
    Try converting the mp3 to another format like WAV, then convert back to mp3 with a different program. WAV is lossless, but when you convert back to mp3 you might lose some sound quality.
    Thu, 18 Jun 2009, 21:30
    JL235
    Dither Update: I tried putting Jay's test.mp3 into my code in Blitz, and it worked there, too. Now I'm really confused!
    Then the problem must be related to how your MP3 is encoded. Try different software or encode it as a .ogg.
    Fri, 19 Jun 2009, 14:36
    Dither
    JL235 and CodersRule:

    What's strange is that I sent my MP3 to a friend with Blitz3d and it worked for him. Also, I tried converting it to an OGG earlier and it still didn't work for me.

    Maybe I will ask my friend to compile the code, with my MP3, to an .exe.

    Anyway, thanks for the suggestions. I don't want to take up any more of your time with this strange problem. I might just try reformatting my hard drive (it's been a while) and see if that clears things up.