Sujet : Re: [programming in c] bitmap gramophone
De : fir (at) *nospam* grunge.pl (fir)
Groupes : comp.lang.cDate : 02. Apr 2024, 13:29:17
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <uugtk2$3r0fc$1@i2pn2.org>
References : 1 2
User-Agent : Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
fir wrote:
fir wrote:
>
than i run the playback just from teh screen data
so i can play bitmap data like sorta of bitmap
gramophone (hovever playing bitmaps genarally makes
mostly if not ony some buzzes not much interesting)
>
i mean normal graphical bitmaps sound like buzzes
whan those that are generated from loaded vaw - it is those
who are mess soound like music
>
so regular imeges give buzes but mess images give music
some things showed imo
1) the vaves seem to be 16 bit signed, so drawing it as a bitmap
not fully works cos -min and +max have nearly the same color on screen
(0x8000 is lowest 0x7fff is max)where 0 sound and -1 sound have quite different colors 0x0000 and 0xffff) - but at least it seems i generati it right (?)
unsigned short val=amplitude*127*256*sin(t);
i rewritten the code
void buffer_add_sinwave(int len, float amplitude, float hz)
{
for(int i=wave_pos; i<wave_pos+len; i++)
{
if(i>big_ofscreen_buffer_size_x*big_ofscreen_buffer_size_y) continue;
float cycle = 22050.0/hz;
float t = 2*M_PI*fmod(i,cycle)/cycle;
unsigned short val=amplitude*127*256*sin(t);
big_ofscreen_buffer[i] = val;
}
wave_pos+=len;
return;
}
but there seem to be a problem with high frequenzy at all
and i seem not to understand something
if 20.1 khz is 20100 pixels per second (send to waveOut which is set to
take 20.1khz 16 bit 1 channel) then how i can draw 20.1 khz when
one 'period' 'wave' is 1 pixel ? it seems i could draw at most 10.06 khz
az tost when one wave will be then 2 pixels width - hovever if i draw it it seem al sound a lot higher
this overally might mean i should possibly sqwitch to 44.2 khz or even more
to ba able to draw 22 kh with 2 pixels or more
istnt it?
(i know maybe nobody here was doing such lowlewel audio but i post it
becouse it seem generally lowlewel in interestuing - and c is big part about lowlewel imo)