CTX Sound Shots

Blake Shaw
10/8/03

Setup

SetDirectory["~/Desktop/Plasma/CTXSounds/CTX Data Files 2"]

\(\(fileList\  = \ {"4175FAST_21", "4192FAST_22", \ "4221FAST_21", \ "4221FAST_22"};\)\)
dataList  =  {};

For[i = 0,  
      i < Length[fileList],  i++, 
theFile  =  
        OpenRead[
          fileList[[i + 
                  1]] <> ".DAT"]; 
SetStreamPosition[
        theFile, 0]; 
d  =  
        ReadList[theFile,  Real]; 
Close[
        theFile]; 
dataList  =  
        Append[dataList,  d];
]

tfd[x_List, windowSize_:  200,  padSize_:  1]  :=  
      Module[{i, j, n, pad,  window,  xw,  xf,  
          result}, 
n  =  
          Length[x]; 
pad  =  
          Table[0,  {i,  1,  
              windowSize padSize}]; 
window  =  
          Table[If[
                i  ≤  
                  windowSize/2,  (i - 1) , (windowSize  -  
                    i)],  {i,  1,  
                windowSize}]/(0.5 windowSize); 
result  =  {}; 
Do[
          xw  =  Take[
              x,  {j, j + windowSize - 1}];  
xw  =  
            xw  -  (Plus  @@  xw)/n;   (* 
            remove average *) 
xw  =  
            Join[pad ,  (xw window),  
              pad]; 
xf  =  
            Fourier[xw]; 
result  =  
            Append[result,  
              Abs[Drop[
                  xf, -Floor[Length[xf]/2]]]], 
{j,  
            1,  n - windowSize  - 1,  
            windowSize/2}]; 
Transpose[result]]

Plot the Data

\(For[i = 0, \ 
      i < Length[fileList], \ \(i++\), 
	\(ListPlot[
          dataList[\([i + 1]\)], \ PlotRange\  -> \ All, \ 
          PlotLabel\  -> \ "Shot: "\  <> \ 
              fileList[\([i + 1]\)]];\)
]\)

Make the Sounds

For[i = 0,  
      i < Length[fileList],  i++, 
d  =  
        dataList[[i + 1]]; 
dSound  =  
        ListPlay[d,  SampleRate  ->  8192/2]; 
      Export[fileList[[i + 1]] <> "_Sound.aiff", 
        dSound]
]

TFDs

For[i = 0,  
      i < Length[fileList],  i++, 
frequencySpec =  
        tfd[dataList[[i + 1]]]; 
ListDensityPlot[
        frequencySpec,  Mesh ->  False,  
        PlotLabel  ->  "Shot: "  <>  
            fileList[[i + 1]]];
]