HertzDevil icon

randsho(2).cpp

HertzDevil | PRO | 08/01/13 08:54:34 AM UTC | 0 ⭐ | 588 👁️ | Never ⏰ | []
C++ |

2.22 KB

|

None

|

0 👍

/

0 👎

// http://www.mediafire.com/?s1w45hdijht7026
 
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
 
using namespace std;
 
int main(int argc, char** argv){
    if (argc < 2){
        cout << "random .sho generator (HertzDevil made this)\n";
        cout << "generates mario paint song file randomly\n";
        cout << "usage: randsho [filename] ([size])\n";
        cout << "[filename]: valid filename\n";
        cout << "[size]: length of the song in quarter notes. maximum is 2880, default is 96\n";
        exit(0);}
 
    srand(time(0));
    fstream sho(argv[1], ios::out | ios::binary);
    int songSize = argc >= 3 ? atoi(argv[2]) : 96;
 
    if (songSize < 1 || songSize > 2880){
        cout << "INVALID SONG LENGTH!\n";
        exit(0);}
 
    // .sho header
    sho.put('s');
    sho.put('h');
    sho.put('r');
    sho.put('o');
    sho.put(argc >= 3 ? 3 : 2);
    sho.put(0);
    sho.put(0);
 
    // random title and author. (only 31 chars long, 2 unused bytes)
    for (int i = 0; i < 64; i++){
        sho.put(32 + rand() % 95);}
 
    // ignored currently
    const char* inst = "default.shi";
    sho.write(inst, 11);
    for (int i = 0; i < 21; i++){
        sho.put(0);}
 
    // long .sho inserts header here
    if (songSize > 96){
        // end of loop
        sho.write(reinterpret_cast<char*>(&songSize), 2);
        // loop, boolean
        sho.put(rand() % 2);
        // time signature, 0 for 3/4, 1 for 4/4
        sho.put(rand() % 2);
        // tempo
        sho.put(rand() % 0xA0);}
 
    // song data
    for (int i = 0; i < (songSize > 96 ? songSize : 96)*3; i++){
        // each note is 4 times as common as no note
        int note = rand() % 53;
        // the note
        sho.put(note == 52 ? 0xFF : note % 13 + 1);
        // the instrument
        sho.put(note == 52 ? 0xDF : rand() % 15);}
 
    // short .sho inserts header here
    if (songSize <= 96){
        // tempo
        sho.put(rand() % 0xA0);
        // end of loop
        sho.put(songSize);
        // loop, boolean
        sho.put(rand() % 2);
        // time signature, 0 for 3/4, 1 for 4/4
        sho.put(rand() % 2);}
 
    // fucking done
    sho.close();
    return 0;}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  • Fixzsi icon
    04/05/26 02:42:21 AM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best t33n active cpx link daily updates!
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400