Sound files within Panda3D programs

I have been through the sound tutorial, and looked at the code in sample programs with sound, from what I can tell Panda must only support one type of sound file called- .ogg?

How does one go about converting sound files to this ogg? Why on earth can’t a person use other types of sound files? I have honestly never even heard of this .ogg sound file before, why not a normal sound file format that someone would be able create without getting more software?

I will go look this .ogg up and book mark it so I can download it tonight after midnight so I can start in with some sound.

I have built a cool little Sea-steroids (asteroids) game modding the sample game that came with Panda, it is a blast, I created an exe of the game and we now have it installed on a number of our computers for the kids to play. I uninstalled it as well to make sure that would work as too, everything seems to work awesome, I am a bit surprised that is the first executable program I have ever made.

Now that I have all the graphical portion of Sea-steroids done I wanted to add some sound for when the fish are blown apart and maybe a sound for the bullet initiation to make it a bit more interesting.

The asteroids was the first folder so I decided to read the code and look through everything and then thought I dive in by changing things a bit and see what all happens, after asteroids I will work my way down the list learning how everything works and eventually try to build something myself.

My next goal after sound would be a score keeper for fish blown up and then on to creating a way to move on to new levels when all fish are gone so that I can bring in more different types of fish higher levels more exotic fish and colors etc.

Can anyone give some guidance on sound, do I have to have this .ogg file or can I make something else work?

Oh yeahh almost forgot… When I was packaging the Sea-steroids I found that there a lot of options and things that were missing apparently, how do I access these functions? I figured out the Icon.ico, I figured out the installation.bmp and the license.txt, all of that was simple, but there a lot of other things that I have no idea how to access them or what command or files to use to set them with values etc. This is apparently not needed to get my programs to install and run, but it would be nice to have the ability to make use of them if I want or need to in the future.

Well I have found out that other sound files are useable, I am trying .wav right now…

I have been going through the sound tutorial and I am noticing that what it says to do causes errors.

base = ShowBase()
mySound = base.loader.loadSfx(“path/to/sound_file.wav”)

I get an error of … mulitple spawns/instances of base

I have tried every permutation of these words I could figure, leaving out base, leaving out everything that brought back an error.

I now keep getting errors that state there is no definition, this last time around I got an error of …((AsteroidsDemo instance has no attribute 'mySound".

I have tried copying text from other programs that have sound but none of that has worked either.

Is there an entire dictionary od every sound command and how to write it available? If I could get a description of every line of code that can play a sound in Panda3d it would be quite useful, in fact a list of all functions and syntax, definitions would be amazingly handy.

The tutorials seem to hit very lightly on each subject but do not give any actual information for the most part. Is there an all inclusive manual that can be downloaded anywhere?

Ogg is mp3s pretty sister. It’s a free and open format (well vorbis. is the format, ogg is the container), unlike wav it has good size, unlike mp3 you don’t need fear lawyers. If you haven’t found any audio software yet I recommend Audacity audacityteam.org/download/

I think you might also want to find some Python tutorial, if you never used it before.

I am able to use .ogg files now, I still cannot find any working script for sound, panda3d or python on the internet or any kind of tutorial that actual has you call a sound file from step a to step b.

I am beginning to think that something within the egg files may be needed ie, I change an existing programs main.py file and do not make a proper corresponding change within the .egg file and so the coding that I add causes an error to return making it appear that particular coding does not work.

In reading through a hundred or more main.py and other files last night I found a lot of files that appear to be called by some of the sample game programs, so rather than some ephemeral hidden function from within the hidden universe of Panda3d it now appears that these are simple script files being called, with that knowledge I simply need to reread through the main.py sample game files how they call these scripts and pay attention to what function they describe in the written comments on those particular scripts being called.

The .egg files are still throwing me, I can find no defined template for what they are, what all is actually in them etc, and they are completely understandable upon simply opening and reading them , many values but no way for me to delineate what the values are or how one would know they need it or how to enter it in there. I came to the conclusion last night that the .egg files are very likely generated by Panda3d itself, that seems most likely anyways.

I have written a number of stand alone Main.py files to get a single sound to play, but in 100 tries or so using code from the tutorial and or code copied from within existing and working game samples calling sound I have not yet even gotten something that would actually run let alone play a single sound. I have done a few dozen searches on the net for Panda3d sound script and then for python sound script, sound code, tutorials, directions, libraries, walk through, I have not as yet been able to find a single thing that actually walks a person through anything, I have found lots of information on individual commands and how they work but none of that works stand alone by itself.

What would be perfect for me is a literal… open wordpad… type this " " first line… type this second line etc etc etc… to play one simple sound… then on to pausing the sound withint this program… then on to looping the sound… then on to attaching the sound to an object… then on to collision of the object etc etc etc… Does something like this exist, that to me is a tutorial, what is in the Panda3d sound tutorial does not appear to be what I am describing, unless I am really missing something, which is very possible. What is very obvious to others may not be so to me, I need very literal fully inclusive step by step instruction, now once I have done it I never need instruction again it is easy beyond that point.

I am sorry to be such a pain, I honestly have spent around 18 hours searching for enough information on Panda3d sound to play a single sound from within a program and I have been unable to find enough information for any success at all. It is clear that I need to go a different route to gain this information.

My past programming makes this all a little bit tricky for me, when I learned to program I learned several different machine languages and I programmed having a several hundred page book lining out all of the circuitry of the computer, I could literally follow any command input all the way through the chains of gates to what the output registry would do in response to the input. I had to manually calculate the fire control solution to hit an airplane moving at x speed and x vector at x altitude from a ship moving at x vector and x speed, I had to calculate where to aim to meet the aircraft, what angle to aim at etc and then program that into a computer manually using an 8 register button keyboard to load all the values needed to launch the missile. I am incredibly literal and I am used to having every possible piece of information able to be fully defined.

This kind of programming is more like trying to catch smoke in my hands as it passes through the air, it is going to take some changes in how approach things I think, and likely a bit of patience from the forum community I fear…

Have You looked in the Manual?
(The manual is also available as a off-line, downloadable archive of web pages: panda3d.org/download/panda3 … python.zip)

This is the code from the manual:

#if ShowBase is not initialized yet
base = ShowBase()
mySound = base.loader.loadSfx("path/to/sound_file.ogg")
#to play the sound
mySound.play()
#to stop the sound
#mySound.stop()

My advice is - save yourself the pain, download the manual, read it, all of it. That’s how I started (I actually had the manual printed).
We also have the reference, a list of all the classes and functions in Panda3D (direct download: panda3d.org/download/panda3 … python.zip ) it’s great help, but I don’t think you can learn the basic just reading the reference.

I did not know there was an actual manual… I went to Python and copied and pasted every page they had on tutorials, every page of the library and everything else I could find, so now I have that.

In the process I found out about downloading Notepad++ and using Windows Powershell, though the tutorial I was going through at that time was apparently a bit old and would not work with python 3.5 or it is my windows 7 platform, but none of the commands he gave would work, but it got me headed in the right direction at any rate.

Between mass searches on Python and Panda3d and this forum hopefully I can figure this all out. So far I am quite enjoying myself, I am in information heaven at the moment, now go read the 1,000 pages or so material I have… That will keep me busy until morning…

I have tried that bit of code you posted, it just returns errors, that is in the tutorial on sound on the panda3d tutorials.

I should ask, is it a problem to use the MSdos prompt to run the programs in? Honestly before two hours ago I was not aware that was such a thing as the “Windows powershell”…

I may have to go back try some of this through the powershell and see if things work differently. I should also ask if it is a problem to do the scripting for the.py in the regular windows notepad or wordpad as I have been doing. I just simply change the file extension from .py to .txt to view them and then change them back to .py after making changes within them. This method seems to work quite well with .xml files so I figured it would also work for the .py files. I am not sure what the difference in notepad++ is but I now have that to use rather than regular windows notepad or wordpad.

Notepad ++ will give you syntax highlights, show indentation and matching parentheses, and some other useful toys. If you don’t need that you can use Notepad or any other editor. The same is true for Powershell vs Cmd (command.com, dos-prompt, console, or whatsoever MS calls it) - both work, use what you like.

You will need to paste the script you use here on the fora, or at least the error message you get, if you want to get more help. I for one can’t guess what you did wrong :wink:

Sorry, I should have started with what I did and what happened I suppose, though honestly I figured I was simply making some incredibly stupid mistake because I was completely some missing some idea or concept that someone would easily catch and correct me on.

Ok, here goes… This is my latest test using the code pasted here on this page, it is also the code from the Pnda3D tutorial as I remember, I tried that code and every permutation of it yesterday. I simply removed each thing that caused an error, hoping to get it to a point that there was some code left that did not return an error and potentially learn from that. It did not work, I kept getting errors until there was no code left.

  1. Created a file folder named … alatest… file path… c:\Panda3D-1.9.1-x64\alatest\

  2. Created a folder named… sound… file path… c:\Panda3D-1.9.1-x64\alatest\sound

  3. I copied and pasted a small sound byte I created last night into my “sound” folder

  4. Created a file named “Main.txt” file with Notepad.

  5. I copied and pasted this code into notepad file named… Main.txt

#if ShowBase is not initialized yet
base = ShowBase()
mySound = base.loader.loadSfx(“Panda3D-1.9.1-x64/alatest/Sound/bloop2.wav”)
#to play the sound
mySound.play()
#to stop the sound
#mySound.stop()

As can be seen I added my path in place of the example… I changed to sound file the bloop2.wav.

  1. I then renamed “Main.txt” to “Main.py”

  2. I opened MSDos prompt and and entered… cd c:\

  3. I then entered … cd Panda3D-1.9.1-x64\

  4. I then entered… cd alatest\

  5. I then typed… ppython Main.py… depressed “enter” key

  6. this action returns this message

Traceback :
File “main.py”, line 2, in
base = ShowBase()
NameError: name ‘Showbase’ is not defined

c:\Panda3D-1.9.1-x64\alatest>

This system…

Windows 7 Home premium, Service Pack 1

Processor… Pentium® Dual-Core CPU E5300 @ 2.60 GHz, 2.60 GHz
Installed memory… 6.00 GB
System type… 64-bit Operating system

I downloaded the 64 bit version of Panda3D

I already had Python 3.5 installed before installing Panda3D

Graphics… according to DXDiag…

Intel® G33/G31 Express Chipset Family
Intel Corporation
Chip type… Intel® GMA 3100
DAC type… Internal
total memory… 256 MB
Current display mode… 1440 x 900 (32bit) (60Hz)
Monitor Generic Pnp Monitor

Drivers… igdum64.dll,jgdumdx32
Version… 8.15.10.1930
DDI version 9Ex
Driver Model: WDDM 1.0

Direct draw Acceleration… enabled
Direct3D Acceleration … enabled
AGP Texture acceleration… enabled

I have not tried much of the Panda3D on any of the other systems I have, though three of the win8 systems are able to run the sample programs well enough, my wife and two of our kids loaded the Panda3D onto their laptops.

I suppose I really should try this bit of code on one of those computers and see if I get the same result.

Are there better operating systems for Panda3D?

I could run this on any of a number of different platforms…I have an old win 95 still setup, I have a windows Millenium setup, XP pro, XP home pc and and XP home laptop, this Win 7 pc and 5 win8 laptops. Could I make a better choice on platform?

Not sure how you are supposed to go about sound really, but I came up with a way of doing it…

I studied the Music Box sample program and pulled the script components out having to do with sound and I created my own file with them. It took a bit get it working, but once I did I then chopped out one thing at a time until I had just what was needed to play sound.

Nearly peed myself when it finally worked, din’t realize the stereo system was turned up so high…

For anyone else who may be having trouble with sound here is a simple way of getting some sound…


import direct.directbase.DirectStart

Sound = base.loadMusic(‘Sound/Cattlecall.wav’)
Sound.setLoopCount(0)
Sound.setVolume(1)
Sound.play()

base.run()

The first line is needed to create a window, I am sure there are other ways to go about this but at the moment it was all I new, this was a piece out of a tutorial that simply opened a blank window, I could not get the sound to work on it’s own and I could not get bas stuff defined so I went with the blank window code and it works.

I simply added a “{sound” folder in my main folder with the main.py file and copied the sound files into the folder.

Sound set volume, from what I understand 1 is full sound and goes down to 0 no sound.
set loop count is the number of times it will play the sound file, o will infinitely loop, 1 will play one time, 2 twice etc on and on…

If anyone else is having trouble with sound, hope this helps, I could find nothing useful in tutorials but with some creative experimentation got err done…

I am unable to get the tutorial code to work at all, but I found I could modify it to get it work.

#if ShowBase is not initialized yet
base = ShowBase()
mySound = base.loader.loadSfx(“Panda3D-1.9.1-x64/alatest/Sound/bloop2.wav”)
#to play the sound
mySound.play()
#to stop the sound
#mySound.stop()

Change to

import direct.directbase.DirectStart

mySound=base.loader.loadSfx(“Sound/Cattlecall.wav”)
mySound.setLoopCount(0)
mySound.setVolume(1)
mySound.play()

base.run()

It seems to me that no matter what you have to define, the setloopCount and the volume no matter what, how else will the program know what to do.

You always have to a run command, the bit of code listed on the tutorial for sound fails to put that in, though just adding a run command to it does not make the code work.

I will keep playing around with the sound code a bit and post what I learn here. Right now I am working to insert sound into a program tied to an object collision, I am having some trouble with it, I keep getting indent errors on the added script, then when I get that script to stop having indent errors it causes indent error in other script, it appears that if I am patient and change the indent on every line of code a few times until it runs right I could pull it off but that would take a great deal of time. Time I think that would be better spent studying indentation.

Later all, can’t have too much fun today, I have to drive to town…

seems like you are new to “OOP programing” and “python” and “Panda3D”.
i used to program in ASM lauguage several years ago and i was quite confused in writing Panda3D program. but slowly i understood how things work and now it feels natural writing these programs.
to program, you need data. in Panda, you need data created by you such as the position of a ship, and Panda objects such as a model node or a sound, then you apply you data to these Panda objects. for example
myModelNodePath.setPos((2,3,4))
mySound.setVolume(0.5)
where (2,3,4) and 0.5 are data created by you. how you calculate the position or volume is you business, Panda objects follow you orders (but you have to learn how to call Panda functions from reading manual and reference).
Panda has NodePath and PandaNode, TextNode, Camera node, LensNode etc. and each has its own group of functions (so-called methods in OOP programming), which must be looked up in reference although a small number of the functions are introduced in manual.
NodePath can be confusing to new comers, it’s important to know that they are different from Nodes. the structures of Panda objects are complex, but they are necessary. so new comers must take some time to understand how to use Panda objects.
you can think of Panda functions as those functions you are familiar to. such as mySound.setVolume(0.5) is like storeTheValueOfVolumeToMySound(0.5) in which a memory space is written a floating point value of 0.5 .
after you get used to these , you can write more complex Panda programs.

While I wll not pretend to understand all that you said, thanks for the post, it is helpful.

Yes I am new to all this programming, I was pretty good at Fortran back in the last half of high school 85-86, I wrote a cool (MSpaint ) like, program for drawing pictures, very simple, you defined a color and size, entered an x,y axis and you got a starting dot, then used the arrow keys to run the dot around filling in with that color. My computer class instructor taught classes that program for several years after that, I thought that was pretty cool. My next programming was in the US Navy as an FC, Fire Control man, where I worked with guided missile systems, radar systems and communications systems, but that was all machine language programming.

I have been injured for a while now and been having to reduce my activity a bit, so I decided to mess around with programming, I have now been studying programming on my own for five days, well five days since I started downloading, the actual study and programming maybe 3.5 days… I have 3 teenage boys who are all interested in doing programming, I would like to find a platform that works well and I can get to know and program a bit in and help them with their interests.

I have been reading through the tutorials on Panda3D and the tutorials on Python3.5, but the problem I am having is that when I try to copy what they have nothing works or does what they say it does, but as I have studied more, I am finding that my having the newest versions of everything is causing me some trouble in that many of the tutorials are no well updated yet.

I am catching on though reading through programs and studying how they are put together and what functions they are calling on from the libraries etc. I am starting to get a bit of an idea of how the indenting works, and how things are defined and attached to objects and how variables are being attached. It would be easier and simpler if I could simply look it all up and it simply gave me all the code and how to do it all, but as long as I have already written programs to study I can learn it. The more programs I read the easier and easier it seems. I have read through much of the Panda3D manual now, I didn’t realize that the HTML pages were manual when I first looked, there is a lot of info in there, at this point it is all still a bit like trying to grab smoke but I am getting there…

one thing that is absolutely causing problem, that i notice, is Python 3.5 you use.
try to look inside Panda3d/samples folders, each folder contains a shortcut named “run main.py”. right click the shortcut and select “properties”, you can see the path of an exe file, such as c:\panda3d\python\python.exe . this python.exe is the one you should use , unless you are familiar with Panda and Python.
also, reading py files in samples is another way to learn. if the samples can run, they must be correct.

I have not been using these to run programs, I have been running them through the command prompt… My sample games seem to run fine, well except for 5 of them that I have moved to “non working” folder. The ones that do not work seem to having problems with open GL with my video card. This computer has problems with a number of popular games as well, it will play Morrowind just fine, but absolutely will not play Oblivion or Skyrim due to graphics issues.

I opened one of my “Run main.py” properties, and the path that I have is…C:\Panda3D-1.9.1-x64\python\python.exe -E main.py

I went and tried t run some of these and they seem to work, so I assume that my path is correct for the versions I am using anyways. Up until now I just assumed you ran all programs in the command prompt.

A question, in the two programs that I have used packpanda on, the process worked great by the way, I am quite impressed with that program. But back to my question, they were very simple mods of the asteroids game which is in itself pretty simple, the two packaged .exe’s were 39 and 40 MB, why such a large file for such a small and simple game? Do all programs created with Panda tend to be large?

the library files of Panda3d are large , since they contain many functions. even if your program uses only one function of Panda, the files must be present in the folder. this is one reason a packed game is 40mb in size. when your game becomes more complex, the size won’t grow much unless you use more 3d models, textures, sounds, videos…
unless you distribute a game on internet, 40mb is not too much .
when you learn more about Panda and 3D graphics techniques, you may find ways to make files smaller. but file size should not be your biggest concern when you are at the start of learning.