title: Libgdx popping noise while playing music
body: <p>I have this problem where when I play this certain music with libgdx, I start hearing some soft popping noise in the background while the music is played. I have tried some different audio formats but It doesn't help. In my code the music is the "endmusic".</p>
  
  <p>Here is my whole code: </p>
  
  <pre><code>public class WorldScreen implements Screen{
  
  Preferences prefs;
  
  private Texture bgCity;
  private Texture bgLoop;
  private Texture bgEnd;
  private Texture bgFade;
  private Texture hud;
  
  public static OrthographicCamera camera;
  SpriteBatch batch;
  
  Rectangle player;
  Rectangle background;
  Rectangle backgroundloop;
  
  public float time = 100;
  public float camx = 0;
  public float camy = 0;
  public static float score = 384400000f;
  public static float value = 384400000f;
  BitmapFont font;
  GestureListenerC controller;
  
  private Music startmusic;
  private static Music loopmusic;
  private Music endMusic;
  
  public static boolean ending = false;
  
  private int endint;
  private String endstring = "";
  
  public WorldScreen(final JetpackGame aa) {
  
  }
  
  @Override
  public void render(float delta) {
      Gdx.gl.glClearColor(0, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  
      camx = camera.viewportWidth / 2f;
      camy = camera.viewportHeight / 2f;
  
      controller.update();
      camera.update();
  
      batch.setProjectionMatrix(camera.combined);
      batch.begin();
  
      batch.draw(bgCity, background.x, background.y);
      batch.draw(bgLoop, backgroundloop.x, backgroundloop.y);
      batch.draw(bgEnd, 0, 5360);
  
       if(!ending){
      if(camera.position.y &gt;= 5360) camera.position.y = 4096;
       }
  
      if(value &lt;= 0) ending = true;
      //ENDING
      if(ending){
          time += 0.1f * Gdx.graphics.getDeltaTime();
          startmusic.stop();
          loopmusic.stop();
          if(time &lt;= 102.75f){
              camera.position.y += 0.1 * time;
              if(camera.position.y &gt;= 5360) camera.position.y = 4096;
          }
          if(time &gt;= 102.75f) {
              if (camera.position.y &gt;= 4090 &amp;&amp; camera.position.y &lt;= 6666)
                  camera.position.y += 0.1 * time;
          }
          endMusic.play();
          font.setScale(2.0f);
          font.draw(batch, "You already finished the game xD", 0,1200);
          if(time &gt;= 103.2f)endMusic.stop();
  
      }
  
  
      Matrix4 normalProjection = new Matrix4().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
      batch.setProjectionMatrix(normalProjection);
  
      batch.draw(hud, 0, 85, Gdx.graphics.getWidth(), 1200);
  
      font.setScale(3.5f);
      if(time &lt;=102.5f) {
          font.draw(batch, "&gt;Meters to the moon", 10, 1260);
          font.draw(batch, "&gt;" + (int)value + "m", 10, 1190);
      }
      //font.draw(batch,""+time, 100, 100);
      //font.draw(batch,""+value, 100,120);
      if(time &gt;= 103) {
          font.setScale(3.0f);
          font.draw(batch, "&gt;"+endstring, 10,1200);
      }
  
      if(time &gt;= 104)
      batch.draw(bgFade, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
  
      batch.end();
  
      if(value &lt; 0) value = 0;
  
      if(!startmusic.isPlaying()) {
          loopmusic.setLooping(true);
          loopmusic.play();
      }
  
      //RANDOM ENDING GENERATOR
      switch(endint){
          case 1: endstring = "Now do it again faster!";
              break;
          case 2: endstring = "What are you doing with your life?!";
              break;
          case 3: endstring = "Do you want a cookie?";
              break;
          case 4: endstring = "How many hours did you waste?";
              break;
          case 5: endstring = "So you have no life?";
              break;
          case 6: endstring = "Now get out of your room and go outside!";
              break;
        }
  
  }
  @Override
  public void resize(int width, int height) {
  
  }
  
  @Override
  public void show() {
  
      Random rand = new Random();
      endint = rand.nextInt(6);
  
      font = new BitmapFont();
      font.setColor(Color.GREEN);
  
      Preferences prefs = Gdx.app.getPreferences("My Preferences");
      float value = prefs.getFloat("Value", 384400000f);
  
      controller = new GestureListenerC();
      GestureDetector gestureDetector = new GestureDetector(20, 0.5f, 2, 0.15f, controller);
      Gdx.input.setInputProcessor(gestureDetector);
  
      loopmusic = Gdx.audio.newMusic(Gdx.files.internal("audio/AmbientLoop.ogg"));
      startmusic = Gdx.audio.newMusic(Gdx.files.internal("audio/AmbientStart.ogg"));
      endMusic = Gdx.audio.newMusic(Gdx.files.internal("audio/Moon.ogg"));
      endMusic.setLooping(false);
      startmusic.play();
  
      bgCity = new Texture(Gdx.files.internal("img/city_BG.png"));
      bgLoop = new Texture(Gdx.files.internal("img/loopBG.png"));
      bgEnd = new Texture(Gdx.files.internal("img/endBG.png"));
      bgFade = new Texture(Gdx.files.internal("img/fade.png"));
      hud = new Texture(Gdx.files.internal("img/Hud.png"));
  
      camera = new OrthographicCamera();
      camera.setToOrtho(false, 480,854);
      batch = new SpriteBatch();
  
      background = new Rectangle();
      background.x = 0;
      background.y = 0;
      background.width = 479;
      background.height = 4096;
  
      backgroundloop = new Rectangle();
      backgroundloop.x = 0;
      backgroundloop.y = 4096;
      backgroundloop.width = 512;
      backgroundloop.height = 1024;
  }
  
  @Override
  public void hide() {
  
  }
  
  @Override
  public void pause() {
  
  }
  
  @Override
  public void resume() {
  
  }
  
  @Override
  public void dispose() {
      prefs.putFloat("Value", value);
      prefs.flush();
  
      batch.dispose();
      font.dispose();
      bgCity.dispose();
      bgLoop.dispose();
      bgEnd.dispose();
      bgFade.dispose();
      hud.dispose();
      loopmusic.dispose();
      startmusic.dispose();
      endMusic.dispose();
  }
  
  }
  </code></pre>