5 Replies Latest reply on Jun 13, 2016 11:55 AM by ET.K

    Creating a graph plot from text data file

    ET.K Level 1

      I have a research project where I need to overlay a scrolling graph representing vibrato (sine wave like change of fundamental frequency) of violin performances.

       

      The video below was made some years ago - overlaying was done manually by screen capturing the graph plotted by a frequency analysis program. This was labor intensive because the program could not plot the whole graph in one shot, and I had to capture multiple screens and put them together before importing to AE.

      The program can output the time-frequency text data in one shot (see below), and I am hoping to turn that data into a graph plot in AE, perhaps using stroke effect or something.

       

      Time_s     F0_Hz

      4.993033 238.870532

      5.000533 238.933763

      5.008033 239.104388

      5.015533 239.433866

      ....

       

      I am trying to find an answer myself, but meanwhile I am also asking gurus for any suggestions/pointers.

       

      Thank you in advance for any help.

      Eitaro Kawaguchi, Engineer

      College of Music, Florida State University

        • 1. Re: Creating a graph plot from text data file
          Mylenium Most Valuable Participant

          Would be easy enough. Even the old trick of copy&pasting AE keyframe data to and from Excel, editing the values and sending it back would work as would be parsing the data as arrays of data tuples after removing extraneous info like the headers in an expression or script. The values need massaging, though. Attempting to display frequency differences of a few microns would not even cover a sub-pixel in AE and you would only see a pretty smooth sine. You would have to do some serious range remapping here, at least for the visualization, not an actual value readout. Assuming the sampling interval for the values is always the same, you could get rid of the time values entirely, which would make this even simpler - the X offset would merely be a linear value based on multiplying it with the number of samples (= frames or time fractions). The only caveat might be AE's limited precisison. there's simply no way to squeeze in more than 99 frames per second...

           

          Mylenium

          • 2. Re: Creating a graph plot from text data file
            Rick Gerard Adobe Community Professional & MVP

            Scripting is probably the way to go to generate the keyframes you need from the data. You'll have to consider representation rather than reality to make it work for you.

            • 3. Re: Creating a graph plot from text data file
              ET.K Level 1

              Thank you for the responses.

              I can certainly 'massage' the file before importing, or even formatting it as key frames of an AE object(?).

              Real difficulty for me is 'what' can hold the data to show the 'waveform (graph)' that I can scroll during the course of the video. I can see that by using  F0 value for Y coordinate of an object, a dot can move up and down, but how can I make a layer(s) corresponding to having, say, a 5000x100 PNG file that's the entire graph?

              It may be an obvious thing to an experienced in AE script (expression?), but I'm still at a loss, and a little snippet of actual code example or pointer to a manual page would be greatly appreciated.

              E.K.

              • 4. Re: Creating a graph plot from text data file
                Mylenium Most Valuable Participant

                You can use the Write-On effect or a particle system that drops a particle for every sample or any other method you can fancy that renders a dot or partial stroke dynamically. And you wouldn't necessarily use a huge solid. You simply let the graph scroll using the effects' built-in options like emission direction or additional effects like Motion Tile or Transform. You really need to think differently here. It's a visualization, not an analysis tool.

                 

                Mylenium

                • 5. Re: Creating a graph plot from text data file
                  ET.K Level 1

                  Taking the suggestions from the gurus, this is what I have come up with:

                  1. Processed the original frequency data in Excel so the numbers represent deviation (in cents) from the closest note.

                  -2.294586671

                  -0.508420049

                  -1.265601117

                  -2.813249903

                  ..... etc.

                  2. Pasted above into text file that conforms to AE keyframe import for Y position of an object

                      Adobe After Effects 8.0 Keyframe Data

                            Units Per Second     60

                            Sourse Width          50

                            Source Height     50

                  Source Pixel Aspect Ratio     1

                  Comp Pixel Aspect Ratio     1

                  Transform     Y Position

                       Frame

                  1     -2.294586671

                  2     -0.508420049

                  3     -1.265601117

                  4     -2.813249903

                  .....

                  End of Keyframe Data

                  3. A Comp was made with a null and a black solid, and above was pasted to Y position of the null

                  4. The black solid has "Write-on" effect with following expression and appropriate brush size etc.:

                  <Brush Position>

                  y = thisComp.layer("Null 1").position[1];

                  y = -10 * y + thisComp.height/2;

                  x = thisComp.width * time / thisComp.duration;

                  [x,y];

                  <Stroke Length>

                  thisComp.duration;

                  This comp will plot the graph from left to right

                  5. To freeze the entire graph, above layers were pre-comp'ed and time was frozen at the last frame

                  Now I can use this to show a scrolling graph with video, and text showing cents value can be displayed too.

                  <Source Text>

                  pos = comp("Pre-comp 1").layer("Null 1").position.valueAtTime(time);

                  pos[1].toFixed(2);

                   

                  I guess I could write a script to automate much of above, but this would be good enough for now.

                  Thank you again for the input.

                   

                  E.K.