Sujet : Re: [programming in c] bitmap gramophone
De : spibou (at) *nospam* gmail.com (Spiros Bousbouras)
Groupes : comp.lang.cDate : 02. Apr 2024, 17:00:24
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <O8ztS0ipXpAuqCQ2F@bongo-ra.co>
References : 1 2 3
On Tue, 02 Apr 2024 14:29:17 +0200
fir <
fir@grunge.pl> wrote:
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;
Shouldn't this be break ? When
i>big_ofscreen_buffer_size_x*big_ofscreen_buffer_size_y , it will remain
true for all the other values of i in the loop.
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;
}
Are big_ofscreen_buffer , big_ofscreen_buffer_size_x , big_ofscreen_buffer_size_y
global variables ?