congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
AudioDevice
Code IndexAdd Tabnine to your IDE (free)

How to use
AudioDevice
in
com.badlogic.gdx.audio

Best Java code snippets using com.badlogic.gdx.audio.AudioDevice (Showing top 6 results out of 315)

origin: libgdx/libgdx

  @Override
  public void run () {
    final float frequency = 440;
    float increment = (float)(2 * Math.PI) * frequency / 44100; // angular increment for each sample
    float angle = 0;
    float samples[] = new float[1024];
    while (!stop) {
      for (int i = 0; i < samples.length; i += 2) {
        samples[i] = 0.5f * (float)Math.sin(angle);
        samples[i + 1] = 2 * samples[i];
        angle += increment;
      }
      device.writeSamples(samples, 0, samples.length);
    }
    device.dispose();
  }
});
origin: libgdx/libgdx

  @Override
  public void run () {
    while (true) {
      recorder.read(samples, 0, samples.length);
      device.writeSamples(samples, 0, samples.length);
    }
  }
});
origin: libgdx/libgdx

@Override
public void pause () {
  device.dispose();
  recorder.dispose();
}
origin: tube42/drumon

public void open()
{
  if(ad != null) {
    close();
  }
  System.out.println("DEVICE OUTPUT: opening...");
  int freq = World.freq;
  ad = Gdx.audio.newAudioDevice(freq, true);
  int lat = ad.getLatency();
  System.out.println(
       "AudioDevice latency=" + lat + "samp/" +
       (1000 * lat / (float)freq) + " ms " +
       " freq=" + freq +
       " mono=" + ad.isMono()
       );
}
origin: tube42/drumon

public boolean write(float []buffer, int offset, int size)
{
  try {
    ad.writeSamples(buffer, 0, size);
    return true;
  } catch(Exception e) {
    System.err.println("ERROR " + e);
    return false;
  }
}
origin: tube42/drumon

  public void close()
  {
    if(ad != null) {
      System.out.println("DEVICE OUTPUT: closing...");
      ad.dispose();
      ad = null;
    }
  }
}
com.badlogic.gdx.audioAudioDevice

Javadoc

Encapsulates an audio device in mono or stereo mode. Use the #writeSamples(float[],int,int) and #writeSamples(short[],int,int) methods to write float or 16-bit signed short PCM data directly to the audio device. Stereo samples are interleaved in the order left channel sample, right channel sample. The #dispose() method must be called when this AudioDevice is no longer needed.

Most used methods

  • dispose
    Frees all resources associated with this AudioDevice. Needs to be called when the device is no longe
  • writeSamples
    Writes the array of 16-bit signed PCM samples to the audio device and blocks until they have been pr
  • getLatency
  • isMono

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getApplicationContext (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getExternalFilesDir (Context)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • JTextField (javax.swing)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now