Skip to Content
Swing Hacks
book

Swing Hacks

by Joshua Marinacci, Chris Adamson
June 2005
Intermediate to advanced
544 pages
22h 24m
English
O'Reilly Media, Inc.
Content preview from Swing Hacks
Show Audio Information While Playing Sound #77
Chapter 10, Audio
|
395
HACK
Testing It Out
Launch the DataLineGUI application and you’ll get a file-selection dialog.
Choose a suitable AIFF or WAV, and you’ll see the GUI shown in
Figure 10-8.
This is all well and good for a simple GUI, but there’s one problem: where
the heck is our level meter?! It should be between the filename and the text
area, but it’s totally not there!
Initially, I suspected my repaint code was hosed, but it all seemed correct.
So, right after figuring out the meter width, I added a sanity-check debug
line:
System.out.println ("level = " + level);
And when I ran it, I got a result that I really didn’t want to see:
[aeris:HacksBook/Media/x11] cadamson% java DataLineInfoGUI
got PCM format
got info
got line
opened line
level = 0.0
level = 0.0
level = 0.0
level = 0.0
level = 0.0
And that was on a really loud song, so it wasn’t just a slow fade in. I looked
around to see if there was something special you have to do for
getLevel( )
to work, but there wasn’t.
Figure 10-8. Audio player display with format information
396
|
Chapter 10, Audio
#77 Show Audio Information While Playing Sound
HACK
Then I Googled, and found this post to the javasound-interest mailing list
from February 2003:
Date: Mon, 17 Feb 2003 22:31:21 -0800
Reply-To: Discussion list for ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Learning Swing GUI Programming

Learning Swing GUI Programming

Brian Cole
Java Swing

Java Swing

Robert Eckstein, Marc Loy, Dave Wood
JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

Kathy Walrath, Mary Campione, Alison Huml, Sharon Zakhour

Publisher Resources

ISBN: 0596009070Purchase bookErrata Page