* [9front] bipieren
@ 2021-04-05 6:27 Eli Cohen
0 siblings, 0 replies; only message in thread
From: Eli Cohen @ 2021-04-05 6:27 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 165 bytes --]
Ich habe ein smol bipprogramm gemacht. seit wir haben etwas wie dieser?
ps.
sollt Ich von jetzt sprechen Deutsche vor usieren la OS? hopen Sie understanden!
phew!
[-- Attachment #2: beep.c --]
[-- Type: text/x-csrc, Size: 969 bytes --]
// produce waveform for a "beep"
#include <u.h>
#include <libc.h>
void
usage(void)
{
fprint(2, "usage: %s [-f hz] [-d decay] [-l samples] [-s slide] [-v volume]\n", argv0);
exits("usage");
}
void
main(int argc, char **argv)
{
char *buffer;
short s;
int i;
double hz = 440;
double decay = 0.9998;
int samples = 11025;
double slide = 1.0001;
double volume = 0.3;
ARGBEGIN{
case 'f':
hz = atof(EARGF(usage()));
break;
case 'd':
decay = atof(EARGF(usage()));
break;
case 'l':
samples = atoi(EARGF(usage()));
break;
case 's':
slide = atof(EARGF(usage()));
break;
case 'v':
volume = atof(EARGF(usage()));
break;
default:
usage();
}ARGEND
buffer = malloc(samples * 4);
for (i = 0; i < samples; i++) {
s = cos((double)i/44100 * 2 * PI * (hz - pow(slide, i))) * 32767 * volume * pow(decay, i);
buffer[i*4+0] = buffer[i*4+2] = s & 0xFF;
buffer[i*4+1] = buffer[i*4+3] = (s >> 8) & 0xFF;
}
write(1, buffer, samples * 4);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-05 7:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-05 6:27 [9front] bipieren Eli Cohen
9front - general discussion about 9front
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://inbox.vuxu.org/9front
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V1 9front 9front/ http://inbox.vuxu.org/9front \
9front@9front.org
public-inbox-index 9front
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://inbox.vuxu.org/vuxu.archive.9front
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git