Results 1 to 4 of 4

Thread: [RESOLVED] plotting a wav file

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    39

    Resolved [RESOLVED] plotting a wav file

    I have a simple uncompressed (PCM 32 bit 48000 Hz) WAV file and I want to plot its waveform.
    The waveform actually represents a digital signal a few ms long, so I just need to know when the waveform is high and when it is low.
    I parse the DATA chunk word by word and I just plot values on the screen: it works pretty well... but in several points of the resulting graph I see "peaks", which, when compared to the WAV file, correspond to values over 65000. But the file displayed in Audacity shows no peeks, just kind of a square wave (zeroes and ones).

    What am I doing wrong?
    Last edited by Hack; Jun 12th, 2008 at 06:09 AM. Reason: Added RESOLVED to thread title and green resolve checkmark

  2. #2

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    39

    Re: plotting a wav file

    By the way, this is the WAV signal I am analyzing (raw format):
    http://www.planetmobile.it/jumpjack/sample.raw

    My source:

    Code:
    $typecheck on
    $INCLUDE <Rapidq2.inc>
    
    declare sub move(x as integer,y as integer)
    declare sub start(bt as integer,x as integer,y as integer)
    
    
    dim TypeDraw as integer
    TypeDraw=1
    dim flag as integer
    dim orx as integer
    dim ory as integer
    dim ox as integer
    dim oy as integer
    dim pencolor as long
    dim backcolor as long
    dim Dial as QColorDialog
    
    CREATE Form AS QFORM
      Width = 1200
      Height=503
      Center
    
      CREATE ScrollBox1 AS QSCROLLBOX
        Align=alClient
        color=&hffffff
        CREATE image AS QCanvasEx
          Align=alClient
          OnMouseDown=start
        END CREATE
      END CREATE
    END CREATE
    
    Form.ShowModal
    
    
    
    
    sub Start(bt as integer,x as integer,y as integer) 
    dim i as long
    dim in as qfilestream
    dim data as word
    dim letti as long
    dim factor as long
    dim skip as integer
    dim toskip as integer
    dim prev as long
    dim highplot as long
    dim lowplot  as long
    dim high  as long
    
    highplot = 100
    lowplot = 0
    high= 10000
    factor = 1000
    toskip = 2
    skip = 0
        in.open("F:\documenti\testo\geocities\p800sito\altervista\LedRem\sample.raw",fmOpenRead)
        letti = 0
          while in.eof=0
            letti = letti+1
            in.read(data)
            skip = skip + 1
            if skip<toskip then ' Salta alcuni dati per fare piu' stretta l'immagine
                letti= letti-1
            else
    '            if data>high then
    '                image.line(letti,0,letti,highplot,PenColor)
    '            else
    '                image.line(letti,0,letti,lowplot,PenColor)
    '            end if
                image.line(letti-1,200,letti,200-data/factor,PenColor)
                skip = 0
            end if
            print letti, "  ", hex$(data), "   ", int(data/factor)
          wend
    end sub
    The original signal looks like this (it's not exactly this, I don't have its plotting here right now...).


    The more I get toward the end of the file, the more "spurious" values appear, which results in vertical stright lines in the graph!
    (I'll post a screenshot later)
    Last edited by jumpjack; Jun 12th, 2008 at 03:55 AM.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    39

    Re: plotting a wav file

    well, I rewrote from scratch the program in Excel VBA and it works fine, so I guess it's some sort of strange bug in RapidQ basic (or in my understanding of how RapidQ works...)

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    39

    Re: [RESOLVED] plotting a wav file

    I eventually found out a bug.. in my head! ;-)
    I was considering RAW data as unsigned....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width