Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  OpenAL question  (Read 814 times)
0 Members and 1 Guest are viewing this topic.
Offline Middy

Junior Devvie




Java games rock!


« Posted 2004-08-28 17:02:30 »

Hey I have some trouble with my selfmade soundmanager.

I hear an echo of a previous played sound after running a few other sounds. I have checked the Java side and that particular sound is not being played when I hear it. So I am thinking its some buffer I havent cleared, or I am removing the sound in a wrong way. I have included som of  the code, since othervise the post became too long. The poll method handles starting and stopping sounds


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
      
     
      public void poll(float dt) {
           
                 
            System.out.println(_sourcesBeingPlayed.size());
            //remove sounds that are done
            Iterator I = _sourcesBeingPlayed.listIterator();
            while(I.hasNext()){
                  SoundSource ss = (SoundSource)I.next();
                 
                  //update play time for all sounds playing
                  ss._s._timeBeingPlayed+=dt;
                 
                  //Update velocity and position
                  updateSourcePosition(ss);
                  updateSourceVelocity(ss);
                 
                  if(_debug)
                        System.out.println("checking if sound with source idx "+ss._soundBufferidx+" is done" );
                  //is sound still playing?, if not KILL it
                  if(!(AL10.alGetSourcei(_soundSources.get(ss._soundBufferidx), AL10.AL_SOURCE_STATE) == AL10.AL_PLAYING)){
                        if(_debug)
                              System.out.println("Releasing Source"+ss._soundBufferidx );      
                        //add source back to pool
                        _sourcePool.add(ss);
                       
                        //set sound to not playing
                        ss._s._playing=false;
                        //remove reference
                        ss._s=null;
                        _soundSources.position(ss._soundBufferidx);
                          AL10.alDeleteSources(_soundSources);
                        //kill sound
                        I.remove();
                  }
            }
           
     
           
      //Update listener
    createListener(_soundListener);
           
      //Are there new sounds added? Simple FIFO que
   
      if(_soundQue.size()>0 && _sourcePool.size()>0){
                        boolean done=false;
                       
                        while(!done){
                              //sound Que is empty
                              if(_soundQue.size()==0)
                                    done=true;
                             
                              if(_sourcePool.size()>0 && !done){
                                    if(_debug){
                                          System.out.println("There are "+_sourcePool.size()+" sources left" );
                                          System.out.println("There are "+_soundQue.size()+" sounds in QUE " );
                                    }
                                    Sound s = (Sound)_soundQue.get(0);
                                   
                                    if(_debug)
                                          System.out.println("working with sound " +s);
                                   
                                    SoundSource ss =(SoundSource) _sourcePool.get(0);
                                   
                                    int sourceBufidx = ss.get_soundBufferidx();
                                   
                                    //assign sound to source
                                    ss.assignSound(s);
                                   
                                    //create a new sound buffer
                                    createNewBuffer(ss,sourceBufidx);

                                    //Start playing source
                                    AL10.alSourcePlay(_soundSources.get(sourceBufidx));
                             
                                    //add source to sources being played
                                    _sourcesBeingPlayed.add(ss);
                                   
                                   
                                    //set sound to playing
                                    ss._s._playing=true;
                                   
                                    _soundQue.remove(0);
                                    _sourcePool.remove(0);
                                    if(_debug){
                                          System.out.println("There are now "+_sourcePool.size()+" sources left" );
                                          System.out.println("There are "+_sourcesBeingPlayed.size()+" sounds being played " );
                                          printSoundsBeingPlayed();
                                    }
                                   
                              }else{ //no more sources
                                    done=true;
                                   
                              }
                             
                              //if there are sounds left to be played update their delay times
                              for(int i=0;i<_soundQue.size();i++){
                                    Sound s = (Sound)_soundQue.get(i);
                                    s._timeDelayed +=dt;
                              }
                       

                                   
                  }
     
            }
           
      }
           
      public void printSoundsBeingPlayed(){
           
            //if there are sounds left to be played update their delay times
            for(int i=0;i<_sourcesBeingPlayed.size();i++){
                  SoundSource s = (SoundSource)_sourcesBeingPlayed.get(i);
           
            }
      }

      /**
       * @param sound
       */

      public void stopSound(Sound sound) {


            Iterator I = _sourcesBeingPlayed.listIterator();
            while(I.hasNext()){
                  SoundSource ss = (SoundSource)I.next();
                        if(ss._s==sound){            
                              AL10.alSourceStop(_soundSources.get(ss._soundBufferidx));
                              ss._s=null;      
                              _sourcePool.add(ss);
                              I.remove();
                  }
            }
           
           
      }
}

When do I get my makeMyGameAsILike() extension?
Offline aNt

Senior Devvie




AFK


« Reply #1 - Posted 2004-08-31 13:33:25 »

sod it use FMOD- it kicks ass! the 3d is second to none
Offline Middy

Junior Devvie




Java games rock!


« Reply #2 - Posted 2004-08-31 13:34:37 »

I have no problem with that, when its released by the LWJGL guys I might do that

When do I get my makeMyGameAsILike() extension?
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (51 views)
2014-12-03 16:27:13

CopyableCougar4 (48 views)
2014-11-29 21:32:03

toopeicgaming1999 (115 views)
2014-11-26 15:22:04

toopeicgaming1999 (103 views)
2014-11-26 15:20:36

toopeicgaming1999 (31 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!