Compare commits
No commits in common. "master" and "1.0.0" have entirely different histories.
@ -1,6 +1,6 @@
|
||||
[![Build Status](https://drone.brn.systems/api/badges/BRNSystems/RandMus/status.svg?ref=refs/heads/master)](https://drone.brn.systems/BRNSystems/RandMus)
|
||||
RandMus
|
||||
=======
|
||||
[![Build Status](https://drone.brn.systems/api/badges/BRNSystems/RandMus/status.svg)](https://drone.brn.systems/BRNSystems/RandMus)
|
||||
|
||||
Random Music generator piping into aplay (Linux only)
|
||||
|
||||
|
14
randMus.c
14
randMus.c
@ -1,27 +1,21 @@
|
||||
#include <stdio.h> // putchar
|
||||
#include <stdlib.h> // random generator
|
||||
#include <stdlib.h> // rand
|
||||
#include <time.h> // time
|
||||
|
||||
const int num_samples = 6;
|
||||
|
||||
int main() {
|
||||
|
||||
srand(time(NULL)); // seed random number generator
|
||||
int a[num_samples]; // array of random numbers
|
||||
int i; // loop counter
|
||||
int c; // out character
|
||||
int tmp; // temp character
|
||||
int x; // loop counter
|
||||
int y; // loop counter
|
||||
|
||||
srand(time(NULL)); // seed random number generator
|
||||
|
||||
while (1){
|
||||
|
||||
for (x = 0; x < num_samples; x++) {
|
||||
a[x] = rand() % 20 + 1; // set a[x] to a random number between 1 and 50
|
||||
}
|
||||
|
||||
for (i = 0;i<16000; i++) {
|
||||
for (i = 0;i<16000; i++) { // loop forever
|
||||
c = i >> a[0]; // shift right i by a[0]
|
||||
c = c | i >> a[1]; // or c by i shifted right by a[1]
|
||||
c = c * i; // multiply c by i
|
||||
@ -32,7 +26,5 @@ int main() {
|
||||
c = c ^ tmp; // xor c by tmp
|
||||
putchar(c); // print c
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user