view scanpath.h @ 15:d5758530a039 tip

oF0.84 Retina, and iPhone support
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Tue, 12 May 2015 15:48:52 +0100
parents 0e03760cf2d9
children
line wrap: on
line source
/*
 *  scanpath.h
 *  springstructure
 *
 *  Created by Robert Tubb on 09/06/2011.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef _SCANPATHH
#define _SCANPATHH
#include "lump.h"
#include "spring.h"
#include "json.h"
#include <vector>
struct Element{
    Lump * eLump;
    Spring * eSpring;
    Element(Lump * aLump, Spring * aSpring){
        eLump = aLump;
        eSpring = aSpring;
        
    };
    
};

class ScanPath{
private:
	int numElements;
    int maxElements;
    
    bool audioAccessing;
    bool updateAccessing;

    bool bidirectional;

    vector<Element> pathElements;

    double * wavetableNew;
    double * wavetableOld;
    double * wavetableUpdate;

    double currentLength;
    
    double frameInterpolator;
    double framesPerSample;
    
    

    
public:
    enum scanModes {DISPLACEMENT,SPEED,SPRING_FORCE,YPOS};

    scanModes scanMode;
    double restLength;
    
	ScanPath();
	~ScanPath();
    void init();
    
	void inscribe(double ax,double ay);
	void clear();
    
    void draw();
    void drawCubic();
	
    double getTotalLength();
    int howManyElements();
    

	void addSpring();
	void addLump();
    double getNextSample();
    double getNextSample(double aPhasor);
    double getNextSampleCubic(double aPhasor);
    // redone stuff
    void initWavetables();
    void addElement(Lump* const aLump, Spring * const aSpring);
    Lump * getLump(int index);
    Spring * getSpring(int index);
    
    void updateWavetables();

    Json::Value convertToJsonForSaving();
};

#endif