Advertisement
wandrake

Untitled

Mar 12th, 2012
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.95 KB | None | 0 0
  1. let fileStream = new FileStream(argv.[0], FileMode.Open)
  2. let buffer: byte[] = Array.zeroCreate((2 * _sampleRate) / refreshFrequency)
  3. let streamReader = new BinaryReader(fileStream)
  4. timer.Elapsed.Add(fun _ ->
  5.     let x = streamReader.Read(buffer, 0, buffer.Length)
  6.     let bufferList = Array.toList(buffer)
  7.     let values: float[] = ArrayFromPCM16 buffer
  8.     let chartPoints = PointsFromArray(values, _sampleRate)
  9.  
  10.     let rTransf, cTransf = (ref null, ref null)
  11.     let sizeNew = nextTwoPower values.Length
  12.     let trValues = Array.zeroCreate sizeNew
  13.  
  14.     for i in 0..(values.Length-1) do
  15.         trValues.[i] <- values.[i]
  16.  
  17.     rft.TransformForward(trValues, rTransf, cTransf)
  18.  
  19.     let transfPoints = PointsFromArray(!rTransf, 44100)
  20.    
  21.     sampleChart.newData(chartPoints)
  22.     //sampleChart.Color <- Color.FromArgb(25 * (!counter%10), 25 * (!counter%10), 0)
  23.     transformChart.newData(transfPoints)
  24.  
  25.     if x < buffer.Length then timer.Stop()
  26. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement