Curious re-drawing of waveforms

I was working with Logic and Soundtrack Pro simultanously today. I noticed that Logic started to re-draw the waveforms everytime I switched back from SP.
So I quit SP and restarted Logic. Same thing still happening. I believe I´ve read somewhere in the forum about this, but can´t find it now.
Any explaination why Logic is doing this constant re-drawing? Any help appreciated!
/juhani

I don't think it's my tablet as the path that gets drawn is accurate. Have you had problems with the path not getting re-drawn, but the new one added to the old one?
Here's an example (drawn with a mouse on another computer)
A quick pencil tool path
Trying to reshape, drawing clockwise. I think we can agree that I was close enough on the ends.
Now drawing the path AGAIN from the other direction.
Now if I'm supposed to be drawing a certain direction when reshaping, shouldn't there be some indicator (like an arrow on mouseover, say) how I should draw it?
If drawing direction isn't the issue, then what is?
I'm willing to work the way the tool wants me to but if the official line is "unexpected results may occur"...that really isn't helpful.

Similar Messages

  • How to draw the waveform for Tektronix TDS 500?

    Hi,
    I am working on drawing the 2 waveform graphs for Tektronix TDS 500 by using Labview 6.0. Does any one have any experience and tell me or could you please provide an example ? Thanks a lot.

    Hi Dennis,
    Thanks for your answer. But the programs download from the website that you provide dosen't work. I compiled my own program, and I just want to display the waveforms of the TDS 520D on my labview program on my computer.
    The attachment is my program. Before I use GPIBREAD, I send some commands using GPIBWRITE. The commands is from GETWFM.C download from
    http://www.tektronix.com/site/sw/search/1,1058,,00​.html?page=3&sort=&mode=search&pcat=oscilloscopes&​pseries=tds500&KW=&cname=
    But what I get is some wierd codes, neither string nor number. Could you please help me out? Thanks
    Attachments:
    Monitor.vi ‏239 KB

  • How to draw the waveform while playing the sound

    dear all
    can anyone give me some idea about it?

    Your post isn't all that clear...perhaps you should put up a sample image file on the web somewhere.
    I'm working on JFreeChart, a free (GNU LGPL) chart library for Java:
    http://www.object-refinery.com/jfreechart/index.html
    ...so I'm interested in the kinds of charts that people want to use.
    Regards,
    Dave Gilbert
    www.object-refinery.com

  • Draw an audio waveform from recorded sound

    I have problem with draw static waveform from recorded sound. Here is an example of which I wanted to use: http://cookbooks.adobe.com/post_Draw_an_audio_waveform_from_an_MP3_file-16767.html
    Here is an excerpt of my code, where the recorded sound, and I play it:
        public function startRecording():void
                    stop.enabled=true;
                    soundClip = new ByteArray();
                    microphone = Microphone.getMicrophone();
                    microphone.rate = 44;
                    microphone.gain = 100;
                    microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, microphone_sampleDataHandler);              
                public function stopRecording():void
                    play.enabled=true;
                    microphone.removeEventListener(SampleDataEvent.SAMPLE_DATA, microphone_sampleDataHandler);
                    level.width = microphone.activityLevel * 0;
                    level.height = microphone.activityLevel * 0;
                protected function microphone_sampleDataHandler(event:SampleDataEvent):void
                    level.width = microphone.activityLevel * 1;
                    level.height = microphone.activityLevel * 1;
                    while (event.data.bytesAvailable)
                        var sample:Number = event.data.readFloat();
                        soundClip.writeFloat(sample);
                public function startPlaying(soundClip:ByteArray):void
                    this.soundClip = soundClip;
                    soundClip.position = 0;
                                    sound = new Sound();
                    sound.addEventListener(SampleDataEvent.SAMPLE_DATA, sound_sampleDataHandler);
                    channel = sound.play();
                protected function sound_sampleDataHandler(event:SampleDataEvent):void
                    if (!soundClip.bytesAvailable > 0)
                        return;
                    for (var i:int = 0; i < 8192; i++)
                        var sample:Number = 0;
                        if (soundClip.bytesAvailable > 0)
                            sample = soundClip.readFloat();
                        event.data.writeFloat(sample);
                        event.data.writeFloat(sample); 
    Is there any other way than to save the recorded sound as mp3 (which will also be complicated), or can I use this example given and work on ByteArray? I tried to redo it a little, I'm sitting on this already a lot of time and unfortunately to no avail. Any ideas? Tips?
    I would like to compare the recorded sound with the original. Draw waveform will be the first step. Maybe you also have some tips of how to compare the two sounds?
    I would be very grateful for every answer,
    Lilly

    Maybe not related to your problem, but your plugins list shows outdated plugin(s) with known security and stability risks.
    # Shockwave Flash 10.0 r32
    # Next Generation Java Plug-in 1.6.0_17 for Mozilla browsers
    Update the [[Java]] and [[Falsh]] plugin to the latest version.
    See
    http://java.sun.com/javase/downloads/index.jsp#jdk (you need JRE)
    http://www.adobe.com/software/flash/about/
    See [[No sound in Firefox]] and [[Video or audio does not play]]

  • Faster Audio Waveform Draws

    I sync up my video clips by the waveforms. FCP takes a long time to do this. I have 6 GB of RAM in a G5 Quad but it's still slow. Anybody know any tips to speed up FCP in drawing the waveforms?

    And if I'm not mistaken, the actual drawing of the thumbnails & waveforms on the timeline is done more by the GPU than anything, so it's possible a faster graphics card could help.
    I know that was the case back in my days of editing in Vegas.

  • Problem with drawing in a scrollpane using clipbounds

    Hello
    Setup is a JFrame containing a splitpane with on the left just some config buttons and on the right a scrollpane.
    Inside the scrollpane I want to draw big waveforms.
    This is represented by a long array of 1's and 0's for the Y coordinates.
    On drawing in paintComponents method I allways reconstruct a GeneralPath, based on the Clipbouns returned by the Graphics variable.
    I have to reconstruct the GeneralPath polygon because my data can be millions long. And therefor I have to limit the points that are drawn.
    When I allways reconstruct this GeneralPath, upon scrolling the polygon is shown scrappy, as in the line connecting the points will only be half shown or almost not.
    Resizing the window or just minimize maximize and it is shown ok.
    I do not have this problem when the GeneralPath I construct is only once made upfront and never remade in the paintComponent method.
    But as I need the clipbounds to know which part to construct I need to rebuild this polygon over and over again.
    I have tried to draw it with Line2D.Double but I get almost the same effect, parts of the lines not being drawn ok.
    Below is the code of the Panel inside the ScrollPane responsible for this drawing.
    public class Usr_Test_L extends JPanel
      final static Color bg   = Color.black;
      final static Color fg   = Color.white;
      final static Color wave = Color.red;
      final static Color txt  = Color.green;
      final static Color grid = Color.lightGray;
      private static final BasicStroke SOLID = new BasicStroke(1.0f);
      private static final BasicStroke BOLD  = new BasicStroke(3.0f);
      private double maxX = 0.0;
      private double maxY = 0.0;
      private double gridWidth;
      private double gridHeight;
      private int panelWidth;
      private int panelHeight;
      boolean firstTime = true;
      private double[] xPoints = null;
      private double[] yPoints = null;
      GeneralPath polygon;
      boolean polyOk = false;
      private double waveHeight = 0;
      private boolean gridOn = true;
      private Usr_Test_R scrollPane = null;
      Usr_Test_L(Usr_Test_R scrollPane)
        super(true);
        this.scrollPane = scrollPane;
        buildGui();
      void buildGui()
        setBackground(bg);
        setForeground(fg);
        //Let the user scroll by dragging to outside the window.
        setAutoscrolls(true); //enable synthetic drag events
    //    addMouseMotionListener(this); //handle mouse drags
        repaint();
      private void generateWave(int cycles, double height)
        waveHeight = height;
        xPoints = new double[cycles];
        yPoints = new double[cycles];
        Random r = new Random();
        for ( int i = 0; i < cycles; i++ )
          xPoints[i] = i;
          yPoints[i] = (int)( Math.pow(-1.0,i) ) * ( r.nextInt(2) );
    //      if ( ( i % 10 ) == 0 ) yPoints[i] = height;
    //      else                   yPoints[i] = height + gridHeight;
    //      System.err.println("P"+i+"("+xPoints[i]+","+yPoints[i]+")");
      private void generateSineWave(int cycles, double height)
        waveHeight = height;
        xPoints = new double[cycles];
        yPoints = new double[cycles];
        double j, xval, yval;
        j = 0;
        int i = 0;
        while (i < cycles)
          xval = j;
          yval = Math.sin(j) * 10.0 + 20;
          xPoints[i] = xval;
          yPoints[i] = yval;
          i++;
          j += 0.01;
      public Dimension getPreferredSize()  // <== used because of revalidate, parent scrollpane asks preferredsize ..., so we overruled the method
        return new Dimension(panelWidth, panelHeight);
      public void drawLine(int cycles, int height)
        generateWave(cycles,(int)(gridHeight*height));
        maxX = gridWidth  * cycles;
        maxY = gridHeight * cycles;
        while ( maxX > panelWidth  ) panelWidth  *= 2;
        while ( maxY > panelHeight ) panelHeight *= 2;
    //    polyOk = buildPolygon();
        revalidate();
        repaint();
      public void drawSine(int cycles, int height)
        generateSineWave(cycles,(int)(gridHeight*height));
        maxX = gridWidth  * cycles;
        maxY = gridHeight * cycles;
        while ( maxX > panelWidth  ) panelWidth  *= 2;
        while ( maxY > panelHeight ) panelHeight *= 2;
    //    polyOk = buildPolygon();
        revalidate();
        repaint();
      public void zoomIn()
        gridWidth  *= 2;
        gridHeight *= 2;
        repaint();
      public void zoomOut()
        gridWidth  /= 2;
        gridHeight /= 2;
        repaint();
      private void initPanel()
        Dimension d = getSize();
        panelWidth = d.width;
        panelHeight = d.height;
        maxX = panelWidth;
        maxY = panelHeight;
        gridWidth  = panelWidth / 8;
        gridHeight = panelHeight / 8;
        scrollPane.getHorBar().setUnitIncrement((int)(gridWidth*3));           // times 2 otherwise no clipbounds are allways too small
        scrollPane.getHorBar().setBlockIncrement((int)(gridWidth*3));
        scrollPane.getVerBar().setUnitIncrement((int)(gridHeight*3));
        scrollPane.getVerBar().setBlockIncrement((int)(gridHeight*3));
      public void grid()
        if ( gridOn ) gridOn = false;
        else          gridOn = true;
      private void drawGrid(Graphics2D g2, Rectangle clip)
        if ( ! gridOn ) return;
        // draw grid
        g2.setPaint(grid);
        // new good grid
        double startX = clip.getX() + ( gridWidth - ( clip.getX() % gridWidth ) );
        double endX   = clip.getX() + clip.getWidth();
        double startY = clip.getY() + ( gridHeight - ( clip.getY() % gridHeight ) );
        double endY   = clip.getY() + clip.getHeight();
        double y = startY;
        while ( startX < endX )
          while ( y < endY )
            g2.draw(new Rectangle2D.Double( startX - 0.5, y - 0.5, 1.0, 1.0 ));
            y += gridHeight;
          y = startY;
          startX += gridWidth;
      private boolean buildPolygon(Rectangle clip)
        if ( xPoints != null && yPoints != null )
          polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,xPoints.length);
        else
          return false;
        double x = xPoints[0] * gridWidth;
        double y = waveHeight;
        polygon.moveTo((float)xPoints[0], (float)yPoints[0]);
        for ( int index = 0; index < xPoints.length; index++ )
          x = xPoints[index] * gridWidth;
          y = waveHeight + ( yPoints[index] * gridHeight );
          if ( x > ( clip.getX() + clip.getWidth() ) ) break;
          if ( y < clip.getY() || y > ( clip.getY() + clip.getHeight() ) ) continue;
          if ( x < clip.getX() || x > ( clip.getX() + clip.getWidth()  ) ) continue;
          polygon.lineTo((float)x, (float)y);
        return true;
      private boolean drawLines(Graphics2D g2, Rectangle clip)
        if ( xPoints == null || yPoints == null ) return false;
        double x1 = xPoints[0] * gridWidth;
        double y1 = waveHeight;
        double x2, y2;
        boolean cont = false;
        for ( int index = 0; index < xPoints.length; index++ )
          x2 = xPoints[index] * gridWidth;
          y2 = waveHeight + ( yPoints[index] * gridHeight );
          if ( x1 > ( clip.getX() + clip.getWidth() ) )
            break;
          if ( x2 > ( clip.getX() + clip.getWidth() ) )
            break;
          if ( y2 < clip.getY() || y2 > ( clip.getY() + clip.getHeight() ) )
            cont = true;
          if ( x2 < clip.getX() || x2 > ( clip.getX() + clip.getWidth()  ) )
            cont = true;
          if ( ! cont ) g2.draw(new Line2D.Double(x1,y1,x2,y2));
          x1 = x2;
          y1 = y2;
          cont = false;
        return true;
      public void paintComponent(Graphics g)
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        if ( firstTime )
          initPanel();
          firstTime = false;
        // get clip bounds
        Rectangle clip = new Rectangle();
        clip = g2.getClipBounds(clip);
        // draw grid
        drawGrid(g2,clip);
        // draw waveform
        g2.setPaint(wave);
        g2.setStroke(SOLID);
        if ( buildPolygon(clip) ) g2.draw(polygon);
    //    if ( polyOk ) g2.draw(polygon);
    //    drawLines(g2,clip);
      }

    I have added a standalone testcase for ease.
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import java.util.*;
    public class Scrolling {
        public static void main(String[] args) {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new JScrollPane(new DrawPanel()));
            f.setSize(400,300);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    class DrawPanel extends JPanel {
        private GeneralPath polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,1000);
        private int[] coords;
        public DrawPanel() {
            setBackground(Color.white);
            buildPolygon();
        private void buildPolygon() {
         coords = new int[2000];
            Random r = new Random();
            int height = 80;
            int gridHeight = 10;
            int gridWidth = 10;
         int j = 0;       
            for (int i=0, dir=-1; i<1000; i++, dir=-dir) {
                coords[j++] = i * gridWidth;
                coords[j++] = height + dir*gridHeight*r.nextInt(2);
        private void drawPolygonClipped(Rectangle clip)
    polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,1000);
           polygon.moveTo(0,80);
           for ( int i = 0; i < 2000; i++ )
          if ( coords[i] > ( clip.getX() + clip.getWidth() ) ) break;
          if ( coords[i+1] < clip.getY() || coords[i+1] > ( clip.getY() + clip.getHeight() ) ) continue;
          if ( coords[i] < clip.getX() || coords[i] > ( clip.getX() + clip.getWidth()  ) ) continue;
                polygon.lineTo(coords[i++],coords);
    private void drawPolygon(Rectangle clip)
    polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,1000);
         polygon.moveTo(0,80);
         for ( int i = 0; i < 2000; i++ )
              polygon.lineTo(coords[i++],coords[i]);
    protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
         Rectangle clip = new Rectangle();
         g.getClipBounds(clip);
         drawPolygonClipped(clip);
         //drawPolygon(clip);
    g2.draw(polygon);
    public Dimension getPreferredSize() {
    return new Dimension(1500,500);

  • Help in drawing graphics.

    Hi friends,
    I'm newbie in drawing graphics with Java, and I need some help in a specific part of my program.
    What I want to do is to draw a waveform of a sound file. That waveform is built based on the amplitude of each sound sample. So I have a big vector full of those amplitudes. Now what I need to do is plot each point on the screen. The x coordinate of the point will be its time position in the time axis. The y coordinate of the point will be the amplitude value. Ok... Now I have a lot of doubts...
    1 - can someone give me a simple example on how to plot points in a java app? I know I have to extend a JPainel class, but I don't know much about those paint, and repaint methods. It's all weird to me. I already searched through the tutorial and the web, but I couldn't see a simple, good example. Can someone hand me this?
    2 - Once I know how to draw those graphics, I need to find a way to put a button, or anything like that, in my app, so the user can press that button to see to next part of the waveform, since the wave is BIG, and doesn't fit entirely on the screen. Is this button idea ok? Can I use some sort of SCROLL on it, would it be better?
    Well... I'm trying to learn it all. ANY help will be appreciated, ANY good link, little hint, first step, anything.
    Thanks for all, in advance.
    Leonardo
    (Brazil)

    This will lead you, in this sample you have a panel and a button,
    every click will fill a vector with random 700 points and draw them on the panel,
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class Wave extends Frame implements ActionListener
         WPanel   pan    = new WPanel();
         Vector   points = new Vector();
         Button   go     = new Button("Go");
         Panel    cont   = new Panel();
    public Wave()
         super();
         setBounds(6,6,700,400);     
         addWindowListener(new WindowAdapter()
        {     public void windowClosing(WindowEvent ev)
                   dispose();     
                   System.exit(0);
         add("Center",pan);
         go.addActionListener(this);
         cont.add(go);
         add("South",cont);
         setVisible(true);
    public void actionPerformed(ActionEvent a)
         points.removeAllElements();
         for (int j=0; j < 700; j++)
              int y = (int)(Math.random()*350);
              points.add(new Point(j,y+1));
         pan.draw(points);
    public class WPanel extends Panel
         Vector   points;
    public WPanel()
         setBackground(Color.pink);
    public void draw(Vector points)
         this.points = points;
         repaint();
    public void paint(Graphics g)
         super.paint(g);
         if (points == null) return;
         for (int j=1; j < points.size(); j++)
              Point p1 = (Point)points.get(j-1);
              Point p2 = (Point)points.get(j);
              g.drawLine(p1.x,p1.y,p2.x,p2.y);
    public static void main (String[] args)
         new Wave();  
    Noah

  • Trying To Draw The Wav Form of captured audio

    hi all , im trying to get into audio proccessing at j2me platform
    as a start , i made an application that records audio through the phones microhone and after that drawing the bytearray with its wave form on the canvas.
    i used the following capture encoding:
    "capture://audio?encoding=pcm&rate=8000&bits=8&channels=1"
    the application worked great on the emulators...
    after i tried the application on my mobile (motorola E-1000)
    i realized that my mobile does not support PCM encoding as for audio capturing the device only supports AMR to capture audio :|
    so my question what am i suppose to do to draw the WAveForm of the recorded audio if its stored in bytearray encoded as AMR??
    do i need to convert it to wav?
    is there any other techinque?
    any info will be highly welcome!
    thanks in advance.

    Did u manage to draw waveform of amr file? I've the same task and i 've the same questions: "do i need to convert it to wav? is there any other techinque?"

  • Audio Waveform Missing (or partial) in Timeline

    Here's an odd problem.
    For one of the projects I'm working on the waveform for the audio tracks is missing. When I hit CommandOptionw to turn it on and off, when on there are only the x's you see as it's being built.
    On one of the tracks, not both even though they are in stereo, there is a piece of the waveform.
    I trashed all the waveform caches I can find (although I may have missed some, they set things up haphazardly) the waveform is never built.
    Any ideas? Thanks!
    10.4.10
    FCP 6.0.1
    Intel

    I would hazard a quess that you've pushed fcp system resources to the max. I've been working on syncing up some badly time-coded multicam shoots, using the waveforms to sync them up. On one pair of clips, 1.5 hours each, it took quite a while to draw the waveforms and then fcp was VERY sluggish until I turned them off. That's with 6 gigs of ram on a pretty speedy machine.

  • Detecting audio volume for creating waveform

    Hello all,
    I need to display waveform from a sound file.
    I know to use Graphics in java for drawing lines, etc
    But, I don't know how to get the rate volume of a sound (in miliseconds) for creating a text log looks like:
    23,40,54,32,2,43,4,45With these numbers (coordinates) I will draw a waveform.
    In conclusion: How can I draw a waveform from a sound file in java?

    sabre150 wrote:
    AndrewThompson64 wrote:
    sabre150 wrote:
    ..The magnitude is easy ( Math.abs() ) and the running average is relatively easy.. It is as difficult as it is useful. (I.E. not difficult and not useful).I disagree - I have done it this way for 40+ years. The average of some function of a time series is the average taken over the last N values. The running average is the application of this continuously so the running average at time 't' is is the average taken over the last N samples (t,t-1,t-2 etc) so this has a smoothing effect on the time series. Whether one use abs() on each value or any other function does not change the concept. Maybe not the concept, but certainly the end 'volume' number. If you do not use the abs value, the end volume (in the situation I outlined, where the buffer size covers a single wavelength) would be 0 for sawtooth wave spanning -1 <-> 1, -0.5 <-> 0.5 or -2 <-> 2.
    ..For what the OP is trying to do, square() is probably better than abs() but that is for the OP to decide.
    Further consideration is normally given as to whether or not to do some band pass filtering of the time series prior to taking the running average. I would do so but the OP may decide not to. You lost me with the band pass filtering. I thought that required Fourier transforms, and whenever I have looked up FFTs on the net, the formulae made my eyes cross.
    As to the the calculation of running average. All one needs is a ring buffer containing the last N sample values. Uh-huh. I'm with you there. A buffer of values is also required for RMS calculations.
    ..Care must be taken to stop the build up of rounding errors. ..O..K I was not even considering built up rounding errors when I commented.
    ..An approach to this is to recalculate the mean of the ring buffer.. 'ring buffer'? The group of the last 'n' instantaneous values?
    (quick Google later, confirming same)
    Um.. OK. Forget I ever writ that and pretend I knew it all along. ( Thanks ;)
    ..from scratch every now and again but there are many many approaches.
    ..(the incremental approach can be used where for each sample that arrives one adds it in to the average and removes the oldest from the average). ..Let us assume, for simplicity, that the signal is a sawtooth wave that spans from -1 to 1. The average when you happen to be keeping as many samples as fit in a single wavelength will be exactly 0.5. Assuming that you mean the average of the abs() then yes but the average of the unprocessed signal will be zero and not 0.5.
    Now shift the sawtooth signal to span from 0 to 2 and the average is exactly 1, even though the end user would hear exactly the same signal and volume as the original signal that spanned from -1 to 1.Sorry but I don't see your point. My point was that to an end user, listening to the output, both sawtooth waves would sound identical, indistinguishable, yet the values for the average of the absolute values would be different, while the RMS values would be ..identical.
    Compare that to the [RMS volume|http://en.wikipedia.org/wiki/Root_mean_square]. The RMS value would be identical for the -1 <-> 1 signal, and the 0 <-> 2 signal (both values greater than 0).
    Now you have really lost me. I understand 'mean' . I understand 'root mean square'. Both are 101 concepts. Are you just trying to say that one must perform high pass filtering first (i.e. get rid of the mean prior taking the abs() or square() or whatever)? Again. Huh? I was not ever considering any form of filtering.
    ..With sound recordings this occurs naturally since microphones tend not to be able to measure absolute pressure but I would certainly filter out anything below the standard human low frequency cut-off point.Um.. OK.
    I pointed to some code earlier. That code is used in renderings of sound signals. Its primary purpose is to plot the audio signal itself (real perty like), but I was also interested in offering left/right channel 'volume'. After much successful research (and unsuccessful experimentation), I settled on the RMS as the way to calculate the instantaneous volume.
    You can view the results in both Tracker (designed for individual tracks compatible with Java Sound as well as MP3s) and DukeBox (that is designed to parse/play M3U playlists of JavaSound + MP3 playlists). On the lower left/right of the sound trace rendering, often 'visually boosted' (since RMS values tend to be low, there is an option to display the square root of the actual calculated RMS volume, measured from 0-1, which is the default for most of the the preconfigured renderings) in a real time situation.
    I mention this only for the fact that the OP can use either of those apps. to see the end effect of the RMS style calculation.
    ..Where did the OP go, BTW?

  • How to get audio data in (bytes)

    is there a way to get the bytes of a wav file using jmf (not java sound)
    cause i need to draw the waveform of the audio file (any ideas about that 2)
    thanx in advance for replying.

    well it's a bit complicated u have to know the sample size and the byte sex (bigindian or smallindian) ,the following code is taken from SUN javasounddemo
    it can be downloaded from the SUN site.( i recommend downloading it in order to understand the entire code)
    public void createWaveForm(byte[] audioBytes) {
    lines.removeAllElements(); // clear the old vector
    AudioFormat format = audioInputStream.getFormat();
    if (audioBytes == null) {
    try {
    audioBytes = new byte[
    (int) (audioInputStream.getFrameLength()
    * format.getFrameSize())];
    audioInputStream.read(audioBytes);
    } catch (Exception ex) {
    reportStatus(ex.toString());
    return;
    Dimension d = getSize();
    int w = d.width;
    int h = d.height-15;
    int[] audioData = null;
    if (format.getSampleSizeInBits() == 16) {
    int nlengthInSamples = audioBytes.length / 2;
    audioData = new int[nlengthInSamples];
    if (format.isBigEndian()) {
    for (int i = 0; i < nlengthInSamples; i++) {
    /* First byte is MSB (high order) */
    int MSB = (int) audioBytes[2*i];
    /* Second byte is LSB (low order) */
    int LSB = (int) audioBytes[2*i+1];
    audioData[i] = MSB << 8 | (255 & LSB);
    } else {
    for (int i = 0; i < nlengthInSamples; i++) {
    /* First byte is LSB (low order) */
    int LSB = (int) audioBytes[2*i];
    /* Second byte is MSB (high order) */
    int MSB = (int) audioBytes[2*i+1];
    audioData[i] = MSB << 8 | (255 & LSB);
    } else if (format.getSampleSizeInBits() == 8) {
    int nlengthInSamples = audioBytes.length;
    audioData = new int[nlengthInSamples];
    if (format.getEncoding().toString().startsWith("PCM_SIGN")) {
    for (int i = 0; i < audioBytes.length; i++) {
    audioData[i] = audioBytes;
    } else {
    for (int i = 0; i < audioBytes.length; i++) {
    audioData[i] = audioBytes[i] - 128;
    int frames_per_pixel = audioBytes.length / format.getFrameSize()/w;
    byte my_byte = 0;
    double y_last = 0;
    int numChannels = format.getChannels();
    for (double x = 0; x < w && audioData != null; x++) {
    int idx = (int) (frames_per_pixel * numChannels * x);
    if (format.getSampleSizeInBits() == 8) {
    my_byte = (byte) audioData[idx];
    } else {
    my_byte = (byte) (128 * audioData[idx] / 32768 );
    double y_new = (double) (h * (128 - my_byte) / 256);
    lines.add(new Line2D.Double(x, y_last, x, y_new));
    y_last = y_new;
    repaint();

  • Opening an imovie file

    I'm using final cut, and have been asked to help an african relief organization on a project created in imovie. But when I try to open the .imovieproject files, i can load the clips on the plane, but have no edited files.
    I could export the .mov files, using quicktime pro, and load that into finalcut, but i can't separate tracks. When I try to load the .imovieproject files, it crashes final cut.
    Am I not seeing the final edited files?
    Thanks anyone.

    However, when I load the IMovieProjectFile that was given to me, it again loads all the clips (453) of them, but doesn't create a timeline.
    First, start with a pristine copy of the project as completed by the monk. If there's nothing on the timeline of the project you see now AND all the clips are in the Clips pane, something major has probably gone wrong. Normally the author would NOT have moved everything from the Timeline to the Clips pane.
    That can happen, however, if the iMovie project file was inappropriately emptied at some stage by corruption, or by user error. (Emptying the trash in iMovie 2/3/4 can cause such corruption.)
    When there's clips in the Media folder which iMovie doesn't recognize as the project opens -- called strays -- iMovie offers to place them in the Clips pane. When you next save, that's where they stay. If the project file is empty when it opens, all the clips in the Media folder are considered strays.
    When you save, iMovie automatically updates the project.mov (the movie with the same name as your project) to reflect the new timeline.
    So if all the clips are now in the Clips pane and the project.mov is empty (when played in QT player), most likely a major screw-up has occurred. My guess is you should start over with a pristine copy.
    If the pristine copy has all its clips in the Clips pane too, then you have no choice but to rebuild it from those Clips. But that may not be possible.
    Note that the clips in the Clips pane do not necessarily represent the clips as edited by the monk. If they were once stray clips that iMovie moved to the Clips pane, they are the SOURCE FILES of his clips, not the clips themselves. Each source file may support one clip or many clips, and those clip(s) may reside anywhere in the project. (Not necessarily contiguous.) That means it would be virtually impossible for you to reconstruct the project with those files.
    And one finaly question, in the Audio Waveforms folder are .aiff.snp files and m4a.snp and m4a.wvf files. What are they? I can't seem to make them play or import them.
    Those are files that iMovie uses to draw a waveform of audio clips in the project. They can be ignored. iMovie builds them on its own.
    Stepping back for a moment... It's not clear to me why iMovie is being used to prepare clips for Final Cut. If the goal is to import files from the project's Media folder to Final Cut, that probably won't work. Since a source file may support multiple clips located anywhere in the project, they can't be used for that purpose. (The clips will arrive jumbled in Final Cut.)
    If clips are on the Timeline where they should be, my guess is the best way to get the iMovie project clips into Final Cut is to export the iMovie project to a Full Quality DV movie that you import to Final Cut, or import the project's project.mov into Final Cut. Then everything arrives in the proper order. If necessary, split the movie in Final Cut.
    Karl

  • Weird screen redraws

    hi folks.
    mac newbie here...so please be kind!
    anyhow, whenever I'm recording an audio track, and the screen pages to the next screen after a scroll, I ALWAYS get leftovers on the screen from the previous page (weird waveform bits and things).
    is there some setting in the Mac that I need to change so my Logic screen redraws are clean? and not have little bits of graphics everywhere?
    thanks!!
    cheers
    rich

    Is this only during recording? If so I can comfort you. Logic until today cannot draw the waveform perfect in realtime during recording and this sometimes looks strange. I would call it an adumbration of the waveform. When the recording is finished usually you get a clear picture.
    It will be changed in the 2013 update, as far as I know
    Eddie

  • Help!! Importing audio from FCP

    Hi, I have final cut studio 5 and the problem i have is sending from FCP to STP.
    In the last project i put together i had recorded a lecture and the audio was fine when the lecturer was speaking, but when people asked questions the audio was very poor. As it was a lecture there was no need to edit it so i captured the whole 70min video file in 1 go. I then split the clip up using the blade tool so as that the questions people were asking were in seperate clips to the lecturer talking.
    I then right clicked on a question clip and chose send to STP, it went in but it was the whole audio file from the lecture not just the 20 seconds that i wanted, is there any way i can do this?
    Cheers for your help with this
    Chris

    Hi Chris,
    Had the same problem. This happens because it is a reference clip in STP, always looking to the original media file. Doesn't matter if you cut it in parts in FCpro: it always shows the entire clip in STP. If the original mediafile is long it slows down everything in STP particularly with drawing the waveform
    Solution: finilize your editing in FCpro so you are sure content and lenght are ok; than use the mediamanager to COPY the whole project using 'DELETE UNUSED MEDIA', add handle length etc.
    If you send audio files from this new FCpro project to STP you can work with you 20 seconds audioclip
    Hope this helps
    Bart

  • Audio Wave problem in Viewer (havent seen before)

    Hi,
    This is a problem I havent seen before. I double click my audio in the timeline to work with it in the Preview window but the waveforms dont show up.... I can hear it but can't see anything. And when I scroll left or right (in the preview window) turns to thick black vertical lines mixed with green and gray horizontal lines.
    There's no real science to the problem that I can figure out. It happens to Stereo pair clips and Mono clips. SOmetimes the waveform will show up everywhere but in between the in and out marker.
    It's drivin me nuts. Got any ideas??? Much appreciated.
    chris!
    MacPro   Mac OS X (10.4.9)  

    Every time you turn on the waveform in FCP, it has to generate files that relate back to the waveforms that you are looking at. Sometimes, the cache files get out of whack. Delete them and FCP will draw new waveforms and new cache files.
    If it happens again, just flush those cache files. Not big deal.
    CHL

Maybe you are looking for