Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading row events while playing #8

Open
sphaero opened this issue Nov 2, 2021 · 2 comments
Open

Reading row events while playing #8

sphaero opened this issue Nov 2, 2021 · 2 comments

Comments

@sphaero
Copy link

sphaero commented Nov 2, 2021

First of all my compliments for this player. It works really great!!!

I'm using this player to play mod files while also using the row events to trigger stuff. I.e. I'm using it in demos.

However I feel it must be easier to do. I'm calculating the time and buffer size it takes for a single row to process:

2500/this->modctx.bpm)*this->modctx.song.speed

I then read the current data and send it out with osc:

    note *cur_note = modctx.patterndata[state->cur_pattern] + (state->cur_pattern_pos * 4);

    // acquire values, see http://www.aes.id.au/modformat.html for details
    muint sample = (cur_note->sampperiod & 0xF0) | (cur_note->sampeffect >> 4);
    muint period = ((cur_note->sampperiod & 0xF) << 8) | cur_note->period;
    muint effect = ((cur_note->sampeffect & 0xF) << 8) | cur_note->effect;
    muchar effect_op = cur_note->sampeffect & 0xF;
    muchar effect_param = cur_note->effect;
    char effect_param_hex[3];
    sprintf(effect_param_hex, "%02X", effect_param);
    //muchar effect_param_l = effect_param & 0x0F;
    //muchar effect_param_h = effect_param >> 4;

    zosc_t *oscm = zosc_create("/patternevent", "iiiiics",
                                      state->cur_pattern_table_pos, // song pos
                                      state->cur_pattern,           // pattern nr
                                      state->cur_pattern_pos,       // pattern row
                                      period,   // note
                                      sample,
                                      HEXCHAR[effect_op],
                                      effect_param_hex
                                     );

This is also done for the other channels.

However I run into the situation that sometimes rows are skipped somehow. Perhaps because of a jump in the song or by other means.

I was wondering if anybody had thoughts or hints about how to accomplish this.

@WindowsNT
Copy link

Did you manage to calculate the total time of the song ?

@sphaero
Copy link
Author

sphaero commented Feb 6, 2022

Well that's pretty hard since the song can change it's speed during playing and many mods do this. So there's no easy calculation. You could do it by parsing all the patterns for speed changes and use these for calculation.

Then there's also the issue that many mods can loop forever. Pick your battles 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants