Prepfold to Audio Mathematica Notebook

Glen Langston, November 9, 2004

Import the averaged, best profile.

The notebook assumes a "prepfold" file is input that contains a header and a list of samples spanning one pulsar period

\(\(\(
\)\(
\)\(\(PSR\  = \ 
        Import["PSR_1749.bestprof", \ "Table"];\)\(
\)
    \)\)\)

Mathematica imports text as a table of space separated items.  The input table PSR is an irregular two dimensional structure.

Take [ PSR, 40]

The number of plot bins is the second value after the "Bins" string in the PSR data table

NBINS  = 
      Extract[Extract[ PSR,  Position[ PSR,  "Bins"] + {{0, 2}}], 
        1]

To compute the audio output rate to get the correct sound, we'll need the pulse period in millisconds.

PeriodTopo =  
      Extract[Extract[ PSR,  Position[ PSR,  "P_topo"] + {{0, 3}}], 
        1]

PeriodPulse  =  PeriodTopo;

The end of the table is the pulsar intensity profile.

Profile  =  Take[ PSR,  -NBINS];

Plot the (short) single profile audio segment.

Pulse  =  Part[Profile, All,  2];

Get the min and max values for scaling the audio to range 0 to 1.

MinPulse  =  Min[Pulse];  MaxPulse  =  Max[Pulse]

PlayList  =  (Pulse   - MinPulse)/(MaxPulse  -  
              MinPulse);

ListPlot[PlayList,   PlotJoined ->  True,  
      PlotRange ->  All]

PlaySampleRate   =  1000*NBINS/(PeriodPulse)

Play the (short) single profile audio segment.

ListPlay[ PlayList,  SampleRate  ->  PlaySampleRate,  
      PlayRange  ->  All]

Did you hear a very short blip?

4 Seconds of Sound

To get a reasonable period of audio, compute the number of pulsar repeats required to get 4 seconds of audio.

NperFourSeconds  =  4*1000. /PeriodPulse

Now prepare to make a long play list by merging together a sequence of Play lists of one pulse period

LongList  =  PlayList;

Do [ 
        LongList  =  Join[ LongList,  PlayList],  {n, 
          NperFourSeconds}];

Play the four second repetition of the pulsar period.

ListSound  =  
      ListPlay[ LongList,  SampleRate  ->  PlaySampleRate,  
        PlayRange ->  All]

Export the audio segment to the external world.

\(\(ListPlot[\ LongList, \ PlotJoined\  -> True, \ 
        PlotRange\  -> \ All, \ 
        AxesLabel\  -> \ {\ "Sample (114 Per second)", \ "Intensity"}, \ 
        PlotLabel\  -> \ "PSR 1749-28: Four Seconds of GBT Observations"];\)\)

Export[ "PSR_1749_Best.au",  ListSound,  "AU"]