AirTunes Audio to AppleTV AND AirportExpress? (simultaneously)
I've read that with the "Take 2" update, AppleTV owners can now sit down at iTunes and send music via AirTunes to their AppleTV. Can someone clarify one point here? Can users now send music via AirTunes to both an AppleTV and an AirportExpress AT THE SAME TIME? Does iTunes now allow you to select your AppleTV in the list of "Multiple Speakers", along with other AirportExpresses?
Thanks.
I couldn't be happier right now. I started up iTunes on my PC (which is connected to a whole-house audio system with the EXCEPTION of the room with my big screen and ATV - which is connected wirelessly), made a couple iTunes preferences changes, and started hearning the tunes through the entire house and back yard!!!! My shallow little life is complete.
But wait! It gets better! I sat down on the couch to eat my lunch and watch the screensaver on the ATV scrolls 12 years of family photos with the audio stream continuing. A song came on I didn't like so I "woke up" the ATV, clicked the right advance button and after 1.5 second delay, the ATV CHANGED THE TUNE PLAYING EVERYWHERE IN THE HOUSE! I controlled my PC from ATV - FROM MY COUCH!
Here is the one pref change that made it all possible:
itunes>edit>preferences>advanced>look for remote speakers...>"Allow iTunes control from remote speakers"
This thing ROCKS
Similar Messages
-
Possible to use audio line out and in simultaneously ?
In the current version of MacBook Pro Retina is it possible to use the analog audio line out and line in both simultaneously ? That is playback as well as record analog audio at the same time.
Does anyone know what is the audio hardward platform (Codec, DAC, ADC, etc..) in this machine ?
Thanks!Air has a headset jack.
You can use a splitter
Mics should be USB capable for best results, almost all headset mics are junk quality.
then monitoring or listening thru the headphones
consider using a PRO MIC , such as an Audio Technica AT2020 USB
http://www.amazon.com/Audio-Technica-AT2020-USB-Condenser-Microphone/dp/B001AS6O YC/ref=sr_1_1?ie=UTF8&qid=1390776580&sr=8-1&keywords=at2020+usb
or better still use one of these with pro XLR mics:
http://www.amazon.com/Focusrite-2i2-USB-Recording-Interface/dp/B005OZE9SA/ref=sr _1_1?ie=UTF8&qid=1390776526&sr=8-1&keywords=2i2 -
How do I output Apple TV audio from HDMI and Airplay simultaneously
Is there a way to output Apple TV (2nd Gen.) audio from the HDMI port and Airplay simultaneously? There is no "Multiple Speaker" setting in the "AirPlay setup on the Apple TV.
Not possible.
-
Audio stream - record and listen simultaneously
Hi!
I would like to record and listen RTP stream simultaneously, but I don't know how... I can record to a file OR listen in headphone but just separately.
If i create a datasink for recording on a port I cannot use that port to listen. But in this case how can I listen the audio stream on headphone?
Maybe the good solution would be for me if I could clone the stream but I cannot do, because I get an exception
javax.media.NoProcessorException: Cannot find a Processor for: com.ibm.media.protocol.CloneablePushBufferDataSource@1d8957fThis is the code:
DataSource ds = Manager.createCloneableDataSource(Manager.createDataSource(media_locator));
processor = Manager.createRealizedProcessor(new ProcessorModel(ds, formats, outputType));Has anybody got any idea?
Thanks!
Ric Flairrflair wrote:
Thank You, it was not a big help for me...That's too bad. But considering that JavaSound doesn't handle RTP, and all of the code you've posted in JMF code, that doesn't change the fact that it's a JMF question... -
Simultaneously video to AppleTV and audio to Express?
Hi All, can I simultaneously stream the video output of a movie on iTunes to my projector connected to an AppleTV and the audio output of the movie to speakers connected to Airport Express? When I try to use multiple speakers in iTunes on my Mac it doesn't work. Only output on AppleTV runs, but nothing over the AirportExpress to my external speakers.
Thanks,
MSbalangan wrote:
Do I understand you correctly: the atv will send the movie audio (coming from the ipad via airplay) to the airplay speakers?
No, that will not work.
If playing content on the ATV, directly on the ATV with no iDevice involved, the audio can be sent to AirPlay speakers.
As soon as an iDevice is involved in sending content to the ATV, the option to send audio to the AirPlay speakers is removed. -
I stream video/audio from my iPhone to AppleTV (like YouTube) and it works fine. I want to use headphones on the iPhone so I can stream the video to AppleTV and listen on the headphones, but Airplay will not allow me to select both AppleTV and headphones, I can only select one. How can I watch AppleTV and listen on the headphones?
Thank you.have the same problem. Im using iPad 3 and Apple TV. id like to use the ipad as wireless earphones while i watch the video on the tv. is that even possible?
-
Is it possible to do the audio capture and playback simultaneously?
In short :
Is it possible to do the audio capture and playback simultaneously? . If it is not supported directly by Sun, pl suggest another way to achieve the same.
In detail:
I am doing a voice chat application by using the streaming through UDP . I am able to play the byte stream. But , is it possible to capture sound simultaneously (while playing the audio) to send to the other end?
Edited by: dhillarun on Jan 4, 2008 7:11 AMIf you're Airplaying from you computer, you might be able to do this. Here's what I would try:
Go to the Airplay icon in iTunes. You should see both your Apple TV and your speakers listed as options. Select "Multiple speakers." You'll see both devices together. Turn the volume all the way down on the Apple TV. You should be getting the video on the TV, but only hear audio through the speakers.
Using the "Multiple Speakers" option will sync the output of your devices so that the sound matches the picture.
I haven't tried this myself, but I'm thinking this would work. However, this approach will only work when using Airplay from your computer – not from am iPad or iPhone – as they don’t have the "Multiple Speakers" option (as far as I know). It also won't work with content streamed directly to your ATV, obviously, because there's no way to stream from ATV to other devices.
Let me know if this works. -
Export to AppleTv and 5.1 audio
Why does Quicktime Pro not export 5.1 audio to AppleTv?
I have a few video files which have dolby 5.1 audio in them, Handbrake correctly exports to AppleTv with the 5.1 audio but Quicktime does not.When I record a quicktime movie using the built in mic as the input source, everything is fine. When I use the line in to record sound, I only get sound out of one speaker on playback.
The current System QT structure does not support AC3 audio natively. Even with an AC3 component installed to decode AC3, it is only supported as stereo. The TV player software is modified to recognize/support "passthrough" AC3 operation in a manner similar to the way the Apple DVD Player software handles AC3 but only when the data is properly stored in an M4V container for TV use. -
A quick primer on audio drivers, devices, and latency
This information has come from Durin, Adobe staffer:
Hi everyone,
A common question that comes up in these forums over and over has to do with recording latency, audio drivers, and device formats. I'm going to provide a brief overview of the different types of devices, how they interface with the computer and Audition, and steps to maximize performance and minimize the latency inherent in computer audio.
First, a few definitions:
Monitoring: listening to existing audio while simultaneously recording new audio.
Sample: The value of each individual bit of audio digitized by the audio device. Typically, the audio device measures the incoming signal 44,100 or 48,000 times every second.
Buffer Size: The "bucket" where samples are placed before being passed to the destination. An audio application will collect a buffers-worth of samples before feeding it to the audio device for playback. An audio device will collect a buffers-worth of samples before feeding it to the audio device when recording. Buffers are typically measured in Samples (command values being 64, 128, 512, 1024, 2048...) or milliseconds which is simply a calculation based on the device sample rate and buffer size.
Latency: The time span that occurs between providing an input signal into an audio device (through a microphone, keyboard, guitar input, etc) and when each buffers-worth of that signal is provided to the audio application. It also refers to the other direction, where the output audio signal is sent from the audio application to the audio device for playback. When recording while monitoring, the overall perceived latency can often be double the device buffer size.
ASIO, MME, CoreAudio: These are audio driver models, which simply specify the manner in which an audio application and audio device communicate. Apple Mac systems use CoreAudio almost exclusively which provides for low buffer sizes and the ability to mix and match different devices (called an Aggregate Device.) MME and ASIO are mostly Windows-exclusive driver models, and provide different methods of communicating between application and device. MME drivers allow the operating system itself to act as a go-between and are generally slower as they rely upon higher buffer sizes and have to pass through multiple processes on the computer before being sent to the audio device. ASIO drivers provide an audio application direct communication with the hardware, bypassing the operating system. This allows for much lower latency while being limited in an applications ability to access multiple devices simultaneously, or share a device channel with another application.
Dropouts: Missing audio data as a result of being unable to process an audio stream fast enough to keep up with the buffer size. Generally, dropouts occur when an audio application cannot process effects and mix tracks together quickly enough to fill the device buffer, or when the audio device is trying to send audio data to the application more quickly than it can handle it. (Remember when Lucy and Ethel were working at the chocolate factory and the machine sped up to the point where they were dropping chocolates all over the place? Pretend the chocolates were samples, Lucy and Ethel were the audio application, and the chocolate machine is the audio device/driver, and you'll have a pretty good visualization of how this works.)
Typically, latency is not a problem if you're simply playing back existing audio (you might experience a very slight delay between pressing PLAY and when audio is heard through your speakers) or recording to disk without monitoring existing audio tracks since precise timing is not crucial in these conditions. However, when trying to play along with a drum track, or sing a harmony to an existing track, or overdub narration to a video, latency becomes a factor since our ears are far more sensitive to timing issues than our other senses. If a bass guitar track is not precisely aligned with the drums, it quickly sounds sloppy. Therefore, we need to attempt to reduce latency as much as possible for these situations. If we simply set our Buffer Size parameter as low as it will go, we're likely to experience dropouts - especially if we have some tracks configured with audio effects which require additional processing and contribute their own latency to the chain. Dropouts are annoying but not destructive during playback, but if dropouts occur on the recording stream, it means you're losing data and your recording will never sound right - the data is simply lost. Obviously, this is not good.
Latency under 40ms is generally considered within the range of reasonable for recording. Some folks can hear even this and it affects their ability to play, but most people find this unnoticeable or tolerable. We can calculate our approximate desired buffer size with this formula:
(Sample per second / 1000) * Desired Latency
So, if we are recording at 44,100 Hz and we are aiming for 20ms latency: 44100 / 1000 * 20 = 882 samples. Most audio devices do not allow arbitrary buffer sizes but offer an array of choices, so we would select the closest option. The device I'm using right now offers 512 and 1024 samples as the closest available buffer sizes, so I would select 512 first and see how this performs. If my session has a lot of tracks and/or several effects, I might need to bump this up to 1024 if I experience dropouts.
Now that we hopefully have a pretty firm understanding of what constitutes latency and under what circumstances it is undesirable, let's take a look at how we can reduce it for our needs. You may find that you continue to experience dropouts at a buffer size of 1024 but that raising it to larger options introduces too much latency for your needs. So we need to determine what we can do to reduce our overhead in order to have quality playback and recording at this buffer size.
Effects: A common cause of playback latency is the use of effects. As your audio stream passes through an effect, it takes time for the computer to perform the calculations to modify that signal. Each effect in a chain introduces its own amount of latency before the chunk of audio even reaches the point where the audio application passes it to the audio device and starts to fill up the buffer. Audition and other DAWs attempt to address this through "latency compensation" routines which introduce a bit more latency when you first press play as they process several seconds of audio ahead of time before beginning to stream those chunks to the audio driver. In some cases, however, the effects may be so intensive that the CPU simply isn't processing the math fast enough. With Audition, you can "freeze" or pre-render these tracks by clicking the small lightning bolt button visible in the Effects Rack with that track selected. This performs a background render of that track, which automatically updates if you make any changes to the track or effect parameters, so that instead of calculating all those changes on-the-fly, it simply needs to stream back a plain old audio file which requires much fewer system resources. You may also choose to disable certain effects, or temporarily replace them with alternatives which may not sound exactly like what you want for your final mix, but which adequately simulate the desired effect for the purpose of recording. (You might replace the CPU-intensive Full Reverb effect with the lightweight Studio Reverb effect, for example. Full Reverb effect is mathematically far more accurate and realistic, but Studio Reverb can provide that quick "body" you might want when monitoring vocals, for example.) You can also just disable the effects for a track or clip while recording, and turn them on later.
Device and Driver Options: Different devices may have wildly different performance at the same buffer size and with the same session. Audio devices designed primarily for gaming are less likely to perform well at low buffer sizes as those designed for music production, for example. Even if the hardware performs the same, the driver mode may be a source of latency. ASIO is almost always faster than MME, though many device manufacturers do not supply an ASIO driver. The use of third-party, device-agnostic drivers, such as ASIO4ALL (www.asio4all.com) allow you to wrap an MME-only device inside a faux-ASIO shell. The audio application believes it's speaking to an ASIO driver, and ASIO4ALL has been streamlined to work more quickly with the MME device, or even to allow you to use different inputs and outputs on separate devices which ASIO would otherwise prevent.
We also now see more USB microphone devices which are input-only audio devices that generally use a generic Windows driver and, with a few exceptions, rarely offer native ASIO support. USB microphones generally require a higher buffer size as they are primarily designed for recording in cases where monitoring is unimportant. When attempting to record via a USB microphone and monitor via a separate audio device, you're more likely to run into issues where the two devices are not synchronized or drift apart after some time. (The ugly secret of many device manufacturers is that they rarely operate at EXACTLY the sample rate specified. The difference between 44,100 and 44,118 Hz is negligible when listening to audio, but when trying to precisely synchronize to a track recorded AT 44,100, the difference adds up over time and what sounded in sync for the first minute will be wildly off-beat several minutes later.) You are almost always going to have better sync and performance with a standard microphone connected to the same device you're using for playback, and for serious recording, this is the best practice. If USB microphones are your only option, then I would recommend making certain you purchase a high-quality one and have an equally high-quality playback device. Attempt to match the buffer sizes and sample rates as closely as possible, and consider using a higher buffer size and correcting the latency post-recording. (One method of doing this is to have a click or clap at the beginning of your session and make sure this is recorded by your USB microphone. After you finish your recording, you can visually line up the click in the recorded track with the click in the original track by moving your clip backwards in the timeline. This is not the most efficient method, but this alignment is the reason you see the clapboards in behind-the-scenes filmmaking footage.)
Other Hardware: Other hardware in your computer plays a role in the ability to feed or store audio data quickly. CPUs are so fast, and with multiple cores, capable of spreading the load so often the bottleneck for good performance - especially at high sample rates - tends to be your hard drive or storage media. It is highly recommended that you configure your temporary files location, and session/recording location, to a physical drive that is NOT the same as you have your operating system installed. Audition and other DAWs have absolutely no control over what Windows or OS X may decide to do at any given time and if your antivirus software or system file indexer decides it's time to start churning away at your hard drive at the same time that you're recording your magnum opus, you raise the likelihood of losing some of that performance. (In fact, it's a good idea to disable all non-essential applications and internet connections while recording to reduce the likelihood of external interference.) If you're going to be recording multiple tracks at once, it's a good idea to purchase the fastest hard drive your budget allows. Most cheap drives spin around 5400 rpm, which is fine for general use cases but does not allow for the fast read, write, and seek operations the drive needs to do when recording and playing back from multiple files simultaneously. 7200 RPM drives perform much better, and even faster options are available. While fragmentation is less of a problem on OS X systems, you'll want to frequently defragment your drive on Windows frequently - this process realigns all the blocks of your files so they're grouped together. As you write and delete files, pieces of each tend to get placed in the first location that has room. This ends up creating lots of gaps or splitting files up all over the disk. The act of reading or writing to these spread out areas cause the operation to take significantly longer than it needs to and can contribute to glitches in playback or loss of data when recording.There is one point in the above that needed a little clarification, relating to USB mics:
_durin_ wrote:
If USB microphones are your only option, then I would recommend making certain you purchase a high-quality one and have an equally high-quality playback device.
If you are going to spend that much, then you'd be better off putting a little more money into an external device with a proper mic pre, and a little less money by not bothering with a USB mic at all, and just getting a 'normal' condensor mic. It's true to say that over the years, the USB mic class of recording device has caused more trouble than any other, regardless.
You should also be aware that if you find a USB mic offering ASIO support, then unless it's got a headphone socket on it as well then you aren't going to be able to monitor what you record if you use it in its native ASIO mode. This is because your computer can only cope with one ASIO device in the system - that's all the spec allows. What you can do with most ASIO hardware though is share multiple streams (if the device has multiple inputs and outputs) between different software.
Seriously, USB mics are more trouble than they're worth. -
Not sure that I have selected the correct forum. Hope my questions are clearly stated.
Having problems connecting iMac(late 2006) running 10.7.5 to a Samsung Flat Screen TV using separate audio/speaker cable and HDMI standard cable, mini-DVI to HDMI video converter. TV displays generic Apple galaxy background and "some" windows (e.g. screen resolution choices). It does not show Mail or Safari menus. System preferences' display "gathered" the Samsung and chose its resolution. I did not find a way to select the Samsung as my display.
In addition to having old hardware, we have Verizon FIOS providing internet and TV access. Is there any way to make this work for us? We would like to stream video (Netflix) and view shows from the Web. Do we need Apple TV to do this? Or is it not possible with our old iMac? My husband thinks that our Airport could be a factor.
Thank youLately, I have been seeing a lot of posts with users trying to use their Macs/iMacs to mirror their streaming video from their Macs to an HDTV.
There are, actually, many alternatives to choose from than just from a Mac.
You need to have or invest in a WiFi capable router for all of these examples.
Apple TV only integrates with WiFi and newer Mac hardware. So, if you want to have total integrated experience, if you have a 2011 Mac or newer, you might as well pay the $100 for the AppleTV box.
If you have a older Mac, like I have noticed many users do, then you have other options.
If you want to elimate long cable clutter and having your Mac at the mercy of your TV all of the time, you can still use the AppleTV box independently or purchase cheaper alternative media streaming boxes from Roku, Sony, Boxee or any number of electronics manufacturers that now have media streaming boxes and media streaming capability built into DVD/Blu-ray players.
These eliminate long cable clutter by being close to the HDTV where shorter, less expensive cables can be used.
Another alternative for iPad users is to use an iPad with the USB/HDMI video adapter and use your iPad as the streaming box. This ties up your iPad in much the same way as it does with your Mac, but again the iPad can be close to the TV and use minimal cables to the TV.
Another alternative to is to use a combination of an iPad and your Mac to stream content that is only available to stream online from a computer. In this case, you can use a desktop remote app on your iPad and Mac. A good and cheap Desktop Remote app is Splashtop Remote. This allows you to completely connect your iPad remotely, over Wifi, to your iMac desktop. The app streams both video and sound to the iPad which is still connected to your HDTV. The resultant stream video picture will be smaller than the size of your HDTV, but it will still be plenty large enough to watch. Again, if you own a iPad and an Intel Mac, this method also allows minimal cabling to the TV. -
Maximum audio sample rate and bit depth question
Anyone worked out what the maximum sample rates and bit depths AppleTV can output are?
I'm digitising some old LPs and while I suspect I can get away with 48kHz sample rate and 16 bit depth, I'm not sure about 96kHz sample rate or 24bit resolution.
If I import recordings as AIFFs or WAVs to iTunes it shows the recording parameters in iTunes, but my old Yamaha processor which accepts PCM doesn't show the source data values, though I know it can handle 96kHz 24bit from DVD audio.
It takes no more time recording at any available sample rates or bit depths, so I might as well maximise an album's recording quality for archiving to DVD/posterity as I only want to do each LP once!
If AppleTV downsamples however there wouldn't be much point streaming higher rates.
I wonder how many people out there stream uncompressed audio to AppleTV? With external drives which will hold several hundred uncompressed CD albums is there any good reason not to these days when you are playing back via your hi-fi? (I confess most of my music is in MP3 format just because i haven't got round to ripping again uncompressed for AppleTV).
No doubt there'll be a deluge of comments saying that recording LPs at high quality settings is a waste of time, but some of us still prefer the sound of vinyl over CD...
ACI guess the answer to this question relies on someone having an external digital amp/decoder/processor that can display the source sample rate and bit depth during playback, together with some suitable 'demo' files.
AC -
Connect AppleTV and iMac to same pair of speakers
Hi all,
I have an AppleTV which I would like to use to AirPlay audio over from my iDevice to a pair of wired speakers.
i have an iMac that's currently connected to this pair of speakers.
Is there any inexpensive way I can use the AppleTV and iMac to play audio through the same pair of wired speakers? Thank u!You can only output from Apple TV to connected speakers or ones that are airplay capable. Connecting speakers to an Airport Express will make non-enabled speakers airplay compatible.
You can output from a Mac to multiple speakers using airplay. -
I must say that I am very disappointed in how Apple is handling this. The company released a software update a while ago that included the HDCP or High-bandwidth Digital Content Protection to block the copying of audio and video content as it travels through the net. Due to this update, some of us AppleTV owners may have been experiencing errors while renting, buying or home sharing content through the device. The error is as follows: "This content requires HDCP for playback. HDCP isn't supported by your HDMI connection." Thinking to resolve the problem, I went and bought so far 4 different sets of HDMI cables to include an Apple branded HDMI cable and it did not work. Well, I thought it was going to be the TV since my TV's HDMI ports could not be updated, I went and bought a brand new TV which I did make sure that the ports were HDCP compatible and to my surprise it did not worked either. I reset the device to reinstall the software and nothing happened. This past weekend, I went to the Apple Store and they said, well lets erase and reinstall everything and it should work. The guy comes back and plugged it to a Sony TV where they have their demo AppleTV and it gave him the same error again. He said lets try it one more time and when he cam back the device would not even connect to the HDMI port. I am standing there asking for a replacement, which is fare enough due to the circumstances, and let me remind you that the circumstance is that my AppleTV as well as many others got damaged due to the software update not just normal usage and even though it was out of warranty by 80 days it was not my fault that the software update damaged it. Apple all they said was you either pay for the replacement or buy a new one. I was so angry that all I wanted to do was to throw the darn thing in the trash can in front of people in the mall so they know what's going on. I have always been a firm believer of apple but some times I question their way of doing business with the customers. Now I have a damaged AppleTV at home that I cant use not because of my own fault but because of a malfunction on the update and they make it seem as my fault. So if you are having this same problem, you can try anything, you can go to the Apple store and all I have to say is good luck. Thanks Apple....
Here's how I've "FIXED" it.
Each time I want to watch the Apple TV, I "usually" have to unplug the power cord from the back of the Apple TV, then wait ~15 - 30 seconds, then plug it back in.
Restart takes abouta minute for the signal to be recognized by the TV.
Then all's set, until the next time i turn it on, then its pot luck from there.
AppleTV content, my photos streamed from an IPhone 4, content doesn't matter.
The HDMI cable "condition" is a hoax in my opinion.
When I do the update ( bought the AppleTV Gen 2, days after release ) I'll update if this has gone away.
FWIW, I got this with both the Gen 1 720 AND the Gen 2 1080 models, in different locations (states) and different TV manufacturers: Sony LCD 1080 and Panasonic Plasma 720.
Software fix from Apple I suspect. -
How can I stream videos that come into my imac directly to my AppleTV and then my TV
how can I stream videos that come into my imac directly to my AppleTV and then my TV?
Or... you can just use a 3rd party solution.
Best solution for streaming audio and video to your Apple TV from an Mac or Windows PC... without using iTunes... is Airparrot. You can screen share your Mac to your Apple TV. It even lets you select your overscan/underscan and video quality.
Download it and install. It shows up in your system tray. As long as you are on the same network as your Apple TV, just right click the Airparrot icon and select Apple TV as your Airplay device.
http://airparrot.com
Then hook up your wireless keyboard and mouse and plop on the couch for some supersized web browsing.
It's 20 minute sessions for the free version, $9.99 for full and can gift to someone for $4.99 if you buy for yourself. -
Java Audio Metronome | Timing and Speed Problems
Hi all,
I’m starting to work on a music/metronome application in Java and I’m running into some problems with the timing and speed.
For testing purposes I’m trying to play two sine wave tones at the same time at regular intervals, but instead they play in sync for a few beats and then slightly out of sync for a few beats and then back in sync again for a few beats.
From researching good metronome programming, I found that Thread.sleep() is horrible for timing, so I completely avoided that and went with checking System.nanoTime() to determine when the sounds should play.
I’m using AudioSystem’s SourceDataLine for my audio player and I’m using a thread for each tone that constantly polls System.nanoTime() in order to determine when the sound should play. I create a new SourceDataLine and delete the previous one each time a sound plays, because the volume fluctuates if I leave the line open and keep playing sounds on the same line. I create the player before polling nanoTime() so that the player is already created and all it has to do is play the sound when it is time.
In theory this seemed like a good method for getting each sound to play on time, but it’s not working correctly.
At the moment this is just a simple test in Java, but my goal is to create my app on mobile devices (Android, iOS, Windows Phone, etc)...however my current method isn’t even keeping perfect time on a PC, so I’m worried that certain mobile devices with limited resources will have even more timing problems. I will also be adding more sounds to it to create more complex rhythms, so it needs to be able to handle multiple sounds going simultaneously without sounds lagging.
Another problem I’m having is that the max tempo is controlled by the length of the tone since the tones don’t overlap each other. I tried adding additional threads so that every tone that played would get its own thread...but that really screwed up the timing, so I took it out. I would like to have a way to overlap the previous sound to allow for much higher tempos.
I posted this question on StackOverflow where I got one reply and my response back explains why I went this direction instead of preloading a larger buffer (which is what they recommended). In short, I did try the buffer method first, but I want to also update a “beat counter” visual display and there was no way to know when the hardware was actually playing the sounds from the buffer. I mentioned that on StackOverflow and I also asked a couple more questions regarding the buffer method, but I haven’t received any more responses.
http://stackoverflow.com/questions/24110247/java-audio-metronome-timing-and-speed-problems
Any help getting these timing and speed issues straightened out would be greatly appreciated! Thanks.
Here is my code...
SoundTest.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import javax.sound.sampled.*;
public class SoundTest implements ActionListener {
static SoundTest soundTest;
// ENABLE/DISABLE SOUNDS
boolean playSound1 = true;
boolean playSound2 = true;
JFrame mainFrame;
JPanel mainContent;
JPanel center;
JButton buttonPlay;
int sampleRate = 44100;
long startTime;
SourceDataLine line = null;
int tickLength;
boolean playing = false;
SoundElement sound01;
SoundElement sound02;
public static void main (String[] args) {
soundTest = new SoundTest();
SwingUtilities.invokeLater(new Runnable() { public void run() {
soundTest.gui_CreateAndShow();
public void gui_CreateAndShow() {
gui_FrameAndContentPanel();
gui_AddContent();
public void gui_FrameAndContentPanel() {
mainContent = new JPanel();
mainContent.setLayout(new BorderLayout());
mainContent.setPreferredSize(new Dimension(500,500));
mainContent.setOpaque(true);
mainFrame = new JFrame("Sound Test");
mainFrame.setContentPane(mainContent);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.pack();
mainFrame.setVisible(true);
public void gui_AddContent() {
JPanel center = new JPanel();
center.setOpaque(true);
buttonPlay = new JButton("PLAY / STOP");
buttonPlay.setActionCommand("play");
buttonPlay.addActionListener(this);
buttonPlay.setPreferredSize(new Dimension(200, 50));
center.add(buttonPlay);
mainContent.add(center, BorderLayout.CENTER);
public void actionPerformed(ActionEvent e) {
if (!playing) {
playing = true;
if (playSound1)
sound01 = new SoundElement(this, "Sound1", 800, 1);
if (playSound2)
sound02 = new SoundElement(this, "Sound2", 1200, 1);
startTime = System.nanoTime();
if (playSound1)
new Thread(sound01).start();
if (playSound2)
new Thread(sound02).start();
else {
playing = false;
SoundElement.java
import java.io.*;
import javax.sound.sampled.*;
public class SoundElement implements Runnable {
SoundTest soundTest;
// TEMPO CHANGE
// 750000000=80bpm | 300000000=200bpm | 200000000=300bpm
long nsDelay = 750000000;
long before;
long after;
long diff;
String name="";
int clickLength = 4100;
byte[] audioFile;
double clickFrequency;
double subdivision;
SourceDataLine line = null;
long audioFilePlay;
public SoundElement(SoundTest soundTestIn, String nameIn, double clickFrequencyIn, double subdivisionIn){
soundTest = soundTestIn;
name = nameIn;
clickFrequency = clickFrequencyIn;
subdivision = subdivisionIn;
generateAudioFile();
public void generateAudioFile(){
audioFile = new byte[clickLength * 2];
double temp;
short maxSample;
int p=0;
for (int i = 0; i < audioFile.length;){
temp = Math.sin(2 * Math.PI * p++ / (soundTest.sampleRate/clickFrequency));
maxSample = (short) (temp * Short.MAX_VALUE);
audioFile[i++] = (byte) (maxSample & 0x00ff);
audioFile[i++] = (byte) ((maxSample & 0xff00) >>> 8);
public void run() {
createPlayer();
audioFilePlay = soundTest.startTime + nsDelay;
while (soundTest.playing){
if (System.nanoTime() >= audioFilePlay){
play();
destroyPlayer();
createPlayer();
audioFilePlay += nsDelay;
try { destroyPlayer(); } catch (Exception e) { }
public void createPlayer(){
AudioFormat af = new AudioFormat(soundTest.sampleRate, 16, 1, true, false);
try {
line = AudioSystem.getSourceDataLine(af);
line.open(af);
line.start();
catch (Exception ex) { ex.printStackTrace(); }
public void play(){
line.write(audioFile, 0, audioFile.length);
public void destroyPlayer(){
line.drain();
line.close();Thanks but you have never posted reply s0lutions before ?? And F 4 is definitely not 10 times faster as stated before I upgraded !!
Maybe you are looking for
-
Family using one itunes account, need help
A while back my sister got her first ipod so we set up an account for her using dad's email and credit card. Then I got my own and set up my own library on my computer, but still used dad's itunes account. Eventually I came to realize that any giftca
-
MY iPhone 5 screen smashed ages ago and I got a normal phone shop to repair it and that was 6 month ago my battery and the mother board is broken can apple repair this if I was to pay the bill and not asking them to cover anything
-
Issue in lsmw ; error in read file step
hi, i 'm facing some really strange issue in lsmw.. i have created one header structure and 3 sub structures. until now its working fine but when i created 4th sub structure and in the read file step, its giving the following error : "Generation abor
-
Cannot download firefox to laptop
download hangs at transferring details from maps.google.com
-
Can do everything but rent HD movies...
I have wasted $$ testing the purchase of a song, a tv show but when I try to rent an HD movie, I'm told the ATV is unable to connect to the itunes store, try again later. this has been the case for a couple days now since I bought the unit. any ideas