Tutorial by Examples: audio

Needed imports: import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; This code will create a clip and play it continuously once started: Clip clip = AudioSystem.getClip(); clip.open(AudioSystem.getAudioInputStream(new URL(filename))); clip.start(); clip.loop(Clip.LOOP_CO...
Using the Java-SDK 3.0.1 CountDownLatch lock = new CountDownLatch(1); SpeechToText service = new SpeechToText(); service.setUsernameAndPassword("<username>", "<password>"); FileInputStream audio = new FileInputStream("filename.wav"); RecognizeOpti...
This example shows how to use the IBM Watson Speech to Text service to recognize the type of an audio file and produce a transcription of the spoken text in that file. This example requires Speech to Text service credentials and Node.js Install the npm module for the Watson Developer Cloud N...
Use the HTML or <audio> element to embed video/audio content in a document. The video/audio element contains one or more video/audio sources. To specify a source, use either the src attribute or the <source> element; the browser will choose the most suitable one. Audio tag example: &...
HTML5 provides a new standard for embedding an audio file on a web page. You can embed an audio file to a page using the <audio> element: <audio controls> <source src="file.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audi...
In this example we show how to generate a simple sine wave, and output it on the user's speakers/headphones. let audioContext = new (window.AudioContext || window.webkitAudioContext)(); let sourceNode = audioContext.createOscillator(); sourceNode.type = 'sine'; sourceNode.frequency.value = 261...
Effects can be applied to audio by chaining nodes between the source and the destination node. In this example we use a gain node to mute the source, and only let sound through at specific times. This allows us to create morse code. function morse(gainNode, pattern) { let silenceTimeout = 300; ...
In order to record audio from a user's microphone, we must first gain permission from the user to access the device: navigator.mediaDevices.getUserMedia({ audio: true }) .then(successCallback) .catch(failureCallback); On success, our successCallback will be called with a MediaStream ob...
To play audio using the Web Audio API, we need to get an ArrayBuffer of audio data and pass it to a BufferSource for playback. To get an audio buffer of the sound to play, you need to use the AudioContext.decodeAudioData method like so: const audioCtx = new (window.AudioContext || window.webkitAud...
This example shows how to use two audio sources, and alter one of them based on the other. In this case we create an audio Ducker, that will lower the volume of the primary track if the secondary track produces sound. The ScriptProcessorNode will send regular events to its audioprocess handler. In ...
Add a key named Required background modes in property list (.plist) file .. as following picture.. And add following code in AppDelegate.h #import <AVFoundation/AVFoundation.h> #import <AudioToolbox/AudioToolbox.h> AppDelegate.m in application didFinishLaunchingWithOptions [[...
Java applets are able to load different resources. But since they are running in the web browser of the client you need to make sure that these resources are accessible. Applets are not able to access client resources as the local file system. If you want to load resources from the same URL the App...
//import Speech //import AVFoundation // create a text field to show speech output @IBOutlet weak var transcriptionTextField: UITextView! // we need this audio player to play audio var audioPlayer: AVAudioPlayer! override func viewDidLoad() { super.viewDidLoad() } // this functio...
This is an example how to get the play an audio file which you already have on your pc/laptop .First create a new directory under res and name it as raw like this copy the audio which you want to play into this folder .It may be a .mp3 or .wav file. Now for example on button click you want to pl...
// 1. Instantiate the player. player = ExoPlayer.Factory.newInstance(RENDERER_COUNT); // 2. Construct renderers. MediaCodecVideoTrackRenderer videoRenderer = ... MediaCodecAudioTrackRenderer audioRenderer = ... // 3. Inject the renderers through prepare. player.prepare(videoRenderer, audioRend...
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.requestAudioFocus(audioListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT); changedListener = new AudioManager.OnAudioFocusChangeListener() { @Override public void onAudioFocu...
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.requestAudioFocus(audioListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); changedListener = new AudioManager.OnAudioFocusChangeListener() { @Override public void onAudioFocusChange(in...
First, add the following permissions to the manifest of your project in order to enable device storage access: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> ...
Go through the steps: Add 'NSAppleMusicUsageDescription' to your Info.plist for the privacy authority. Make sure your music is available in your iPhone. It will not work in the simulator. iOS 10.0.1 import UIKit import AVFoundation import MediaPlayer class ViewController: UIViewControll...
using UnityEngine; public class Audio : MonoBehaviour { AudioSource audioSource; AudioClip audioClip; void Start() { audioClip = (AudioClip)Resources.Load("Audio/Soundtrack"); audioSource.clip = audioClip; if (!audioSource.isPlaying) audio...

Page 1 of 2