From: Eli Cohen <echoline@gmail.com>
To: 9front@9front.org
Subject: [9front] bipieren
Date: Sun, 4 Apr 2021 23:27:32 -0700 [thread overview]
Message-ID: <CAHwi9bz1GgU=ZHxY9wsefzYaexHkAykDw07ekcdabo7LT3ESjA@mail.gmail.com> (raw)
[-- 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);
}
reply other threads:[~2021-04-05 7:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHwi9bz1GgU=ZHxY9wsefzYaexHkAykDw07ekcdabo7LT3ESjA@mail.gmail.com' \
--to=echoline@gmail.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).