Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
blablack committed Nov 17, 2014
2 parents d73c0f3 + 095f546 commit 57984e7
Show file tree
Hide file tree
Showing 16 changed files with 518 additions and 360 deletions.
6 changes: 6 additions & 0 deletions src/core/include/hydrogen/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@

#define UNUSED( v ) (v = v)

// m_nBeatCounter
//100,000 ms in 1 second.
#define US_DIVIDER .000001
// ~m_nBeatCounter


#endif // H2C_GLOBALS_H
261 changes: 122 additions & 139 deletions src/core/include/hydrogen/hydrogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <hydrogen/basics/song.h>
#include <hydrogen/basics/sample.h>
#include <hydrogen/object.h>
#include <hydrogen/timeline.h>
#include <hydrogen/IO/AudioOutput.h>
#include <hydrogen/IO/MidiInput.h>
#include <hydrogen/IO/MidiOutput.h>
Expand All @@ -54,100 +55,102 @@ class Hydrogen : public H2Core::Object
H2_OBJECT
public:
/// Return the Hydrogen instance
static void create_instance(); // Also creates other instances, like AudioEngine
static Hydrogen* get_instance() { assert(__instance); return __instance; };
static void create_instance(); // Also creates other instances, like AudioEngine
static Hydrogen* get_instance() { assert(__instance); return __instance; };

~Hydrogen();

// ***** SEQUENCER ********
/// Start the internal sequencer
void sequencer_play();
void sequencer_play();

/// Stop the internal sequencer
void sequencer_stop();
void sequencer_stop();

void midi_noteOn( Note *note );
void midi_noteOn( Note *note );

///Last received midi message
QString lastMidiEvent;
int lastMidiEventParameter;
QString lastMidiEvent;
int lastMidiEventParameter;

void sequencer_setNextPattern( int pos );
void togglePlaysSelected( void );
void sequencer_setNextPattern( int pos );
void togglePlaysSelected( void );
// ***** ~SEQUENCER ********

/// Set/Get current song
Song* getSong() { return __song; }
void setSong( Song *newSong );
Song* getSong() { return __song; }
void setSong ( Song *newSong );

void removeSong();
void removeSong();

void addRealtimeNote ( int instrument, float velocity, float pan_L=1.0, float pan_R=1.0, float pitch=0.0, bool noteoff=false, bool forcePlay=false, int msg1=0 );
void addRealtimeNote ( int instrument,
float velocity,
float pan_L=1.0,
float pan_R=1.0,
float pitch=0.0,
bool noteoff=false,
bool forcePlay=false,
int msg1=0 );

float getMasterPeak_L();
void setMasterPeak_L( float value );
float getMasterPeak_L();
void setMasterPeak_L( float value );

float getMasterPeak_R();
void setMasterPeak_R( float value );
float getMasterPeak_R();
void setMasterPeak_R( float value );

void getLadspaFXPeak( int nFX, float *fL, float *fR );
void setLadspaFXPeak( int nFX, float fL, float fR );
void getLadspaFXPeak( int nFX, float *fL, float *fR );
void setLadspaFXPeak( int nFX, float fL, float fR );

unsigned long getTickPosition();
unsigned long getRealtimeTickPosition();
unsigned long getTotalFrames();
unsigned long getTickPosition();
unsigned long getRealtimeTickPosition();
unsigned long getTotalFrames();

void setRealtimeFrames( unsigned long frames );
unsigned long getRealtimeFrames();
void setRealtimeFrames( unsigned long frames );
unsigned long getRealtimeFrames();

PatternList * getCurrentPatternList();
void setCurrentPatternList( PatternList * pPatternList );
PatternList * getCurrentPatternList();
void setCurrentPatternList( PatternList * pPatternList );

PatternList * getNextPatterns();
PatternList * getNextPatterns();

int getPatternPos();
void setPatternPos( int pos );
int getPatternPos();
void setPatternPos( int pos );

void triggerRelocateDuringPlay();
void triggerRelocateDuringPlay();

long getTickForPosition( int );
long getTickForPosition( int );

void restartDrivers();
void restartDrivers();

void startExportSong( const QString& filename, int rate, int depth );
void stopExportSong( bool reconnectOldDriver );
void startExportSong( const QString& filename, int rate, int depth );
void stopExportSong( bool reconnectOldDriver );

AudioOutput* getAudioOutput();
MidiInput* getMidiInput();
MidiOutput* getMidiOutput();
AudioOutput* getAudioOutput();
MidiInput* getMidiInput();
MidiOutput* getMidiOutput();

int getState();
int getState();

float getProcessTime();
float getMaxProcessTime();
float getProcessTime();
float getMaxProcessTime();

int loadDrumkit( Drumkit *drumkitInfo );
int loadDrumkit( Drumkit *drumkitInfo );

/// delete an instrument. If `conditional` is true, and there are patterns that
/// use this instrument, it's not deleted anyway
void removeInstrument( int instrumentnumber, bool conditional );
void removeInstrument( int instrumentnumber, bool conditional );

//return the name of the current drumkit
QString m_currentDrumkit;
QString m_currentDrumkit;

const QString& getCurrentDrumkitname() {
return m_currentDrumkit;
}
const QString& getCurrentDrumkitname();
void setCurrentDrumkitname( const QString& currentdrumkitname );

void setCurrentDrumkitname( const QString& currentdrumkitname ) {
this->m_currentDrumkit = currentdrumkitname;
}
void raiseError( unsigned nErrorCode );

void raiseError( unsigned nErrorCode );


void previewSample( Sample *pSample );
void previewInstrument( Instrument *pInstr );
void previewSample( Sample *pSample );
void previewInstrument( Instrument *pInstr );

enum ErrorMessages {
UNKNOWN_DRIVER,
Expand All @@ -158,24 +161,24 @@ class Hydrogen : public H2Core::Object
JACK_ERROR_IN_PORT_REGISTER
};

void onTapTempoAccelEvent();
void setTapTempo( float fInterval );
void setBPM( float fBPM );
void onTapTempoAccelEvent();
void setTapTempo( float fInterval );
void setBPM( float fBPM );

void restartLadspaFX();
void setSelectedPatternNumberWithoutGuiEvent( int nPat );
int getSelectedPatternNumber();
void setSelectedPatternNumber( int nPat );
void restartLadspaFX();
void setSelectedPatternNumberWithoutGuiEvent( int nPat );
int getSelectedPatternNumber();
void setSelectedPatternNumber( int nPat );

int getSelectedInstrumentNumber();
void setSelectedInstrumentNumber( int nInstrument );
int getSelectedInstrumentNumber();
void setSelectedInstrumentNumber( int nInstrument );

#ifdef H2CORE_HAVE_JACK
void renameJackPorts();
void renameJackPorts();
#endif

#ifdef H2CORE_HAVE_NSMSESSION
void startNsmClient();
void startNsmClient();
#endif

///playlist vector
Expand All @@ -190,77 +193,35 @@ class Hydrogen : public H2Core::Object
std::vector<HPlayListNode> m_PlayList;

///beatconter
void setbeatsToCount( int beatstocount);
int getbeatsToCount();
void setNoteLength( float notelength);
float getNoteLength();
int getBcStatus();
void handleBeatCounter();
void setBcOffsetAdjust();
void setbeatsToCount( int beatstocount);
int getbeatsToCount();
void setNoteLength( float notelength);
float getNoteLength();
int getBcStatus();
void handleBeatCounter();
void setBcOffsetAdjust();

/// jack time master
unsigned long getHumantimeFrames();
void setHumantimeFrames(unsigned long hframes);
void offJackMaster();
void onJackMaster();
unsigned long getTimeMasterFrames();
long getTickForHumanPosition( int humanpos );
float getNewBpmJTM();
void setNewBpmJTM( float bpmJTM);
void ComputeHumantimeFrames(uint32_t nFrames);

void __panic();
int __get_selected_PatterNumber();
unsigned int __getMidiRealtimeNoteTickPosition();

///sample editor vectors

void sortTimelineVector();
void sortTimelineTagVector();

/// timeline vector
struct HTimelineVector
{
int m_htimelinebeat; //beat position in timeline
// int m_htimelinebar; //bar position from current beat
float m_htimelinebpm; //BPM
// bool m_htimelineslide; //true if slide into new tempo
// int m_htimelineslidebeatbegin; //position of slide begin (only beats, no bars)
// int m_htimelineslideend; //position of slide end (only beats, no bars)
// int m_htimelineslidetype; // 0 = slide up, 1 = slide down
};
std::vector<HTimelineVector> m_timelinevector;

struct TimelineComparator
{
bool operator()( HTimelineVector const& lhs, HTimelineVector const& rhs)
{
return lhs.m_htimelinebeat < rhs.m_htimelinebeat;
}
};
unsigned long getHumantimeFrames();
void setHumantimeFrames(unsigned long hframes);
void offJackMaster();
void onJackMaster();
unsigned long getTimeMasterFrames();
long getTickForHumanPosition( int humanpos );
float getNewBpmJTM();
void setNewBpmJTM( float bpmJTM);
void ComputeHumantimeFrames(uint32_t nFrames);

void setTimelineBpm();
void __panic();
int __get_selected_PatterNumber();
unsigned int __getMidiRealtimeNoteTickPosition();

/// timeline tag vector
struct HTimelineTagVector
{
int m_htimelinetagbeat; //beat position in timeline
// int m_htimelineintensity; //intensity
QString m_htimelinetag; // tag
};
std::vector<HTimelineTagVector> m_timelinetagvector;
void setTimelineBpm();
Timeline* getTimeline() const;

struct TimelineTagComparator
{
bool operator()( HTimelineTagVector const& lhs, HTimelineTagVector const& rhs)
{
return lhs.m_htimelinetagbeat < rhs.m_htimelinetagbeat;
}
};

///midi lookuptable
int m_nInstrumentLookupTable[MAX_INSTRUMENTS];
//void editInstrumentLookupTable( int instrument, int index);
///midi lookuptable
int m_nInstrumentLookupTable[MAX_INSTRUMENTS];


private:
Expand All @@ -273,16 +234,16 @@ class Hydrogen : public H2Core::Object
// beatcounter
float m_ntaktoMeterCompute; ///< beatcounter note length
int m_nbeatsToCount; ///< beatcounter beats to count
int m_nEventCount; ///< beatcounter event
int m_nTempoChangeCounter; ///< count tempochanges for timeArray
int m_nBeatCount; ///< beatcounter beat to count
double m_nBeatDiffs[16]; ///< beat diff
timeval m_CurrentTime; ///< timeval
timeval m_LastTime; ///< timeval
double m_nLastBeatTime; ///< timediff
double m_nCurrentBeatTime; ///< timediff
double m_nBeatDiff; ///< timediff
float m_fBeatCountBpm; ///< bpm
int m_nEventCount; ///< beatcounter event
int m_nTempoChangeCounter; ///< count tempochanges for timeArray
int m_nBeatCount; ///< beatcounter beat to count
double m_nBeatDiffs[16]; ///< beat diff
timeval m_CurrentTime; ///< timeval
timeval m_LastTime; ///< timeval
double m_nLastBeatTime; ///< timediff
double m_nCurrentBeatTime; ///< timediff
double m_nBeatDiff; ///< timediff
float m_fBeatCountBpm; ///< bpm
int m_nCoutOffset; ///ms default 0
int m_nStartOffset; ///ms default 0
//~ beatcounter
Expand All @@ -292,6 +253,9 @@ class Hydrogen : public H2Core::Object
Song::SongMode m_oldEngineMode;
bool m_bOldLoopEnabled;

//Timline information
Timeline* m_pTimeline;

std::list<Instrument*> __instrument_death_row; /// Deleting instruments too soon leads to potential crashes.


Expand All @@ -302,6 +266,25 @@ class Hydrogen : public H2Core::Object

};


/*
* inline methods
*/
inline Timeline* Hydrogen::getTimeline() const
{
return m_pTimeline;
}

inline const QString& Hydrogen::getCurrentDrumkitname()
{
return m_currentDrumkit;
}

inline void Hydrogen::setCurrentDrumkitname( const QString& currentdrumkitname )
{
this->m_currentDrumkit = currentdrumkitname;
}

};

#endif
Expand Down
Loading

0 comments on commit 57984e7

Please sign in to comment.