mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-11-21 16:35:08 -05:00
Start music
This commit is contained in:
parent
e214780e9f
commit
443adbe950
1
assets/sfx_noise.raw
Normal file
1
assets/sfx_noise.raw
Normal file
@ -0,0 +1 @@
|
|||||||
|
yB㊨k頻fw嬌dkq葺。n刹掾p峻ッ<EFBFBD>拝zf|m蛙<cッ枠慾]b嘛gメー義賠》{酢^u`粗n~′赫i暫Zd郭嚼カ學bゥ宜GWN孛g義]d、qZ弛ユcQH笥<48>馬イ秩foj」fkィ}mLfニゥッf<EFBDAF>血J慧|x、ti`e毆エKн<4B>|桷fス溶袈w脹:Nbエ`CゥhSk|争ィ箱<EFBDA8>n3杠|I燕Lsク貌ムmェv生izx@<40>^芸セ晋ネxDサXvァkイz§n師㌃旨x凭」圄\[←u<E28690>]]r勃R屏=pニyi{「Q梼}wvヲsK葡y决sZ~o峽嫺K<E5ABBA>ェ`]izチXlscシ<63>}o{ッ凰ヤ’<EFBE94>}<7D>フ\『co寃渚tOjv<6A>ゥ<EFBFBD>reゥ劉K<E58A89>ィヲ琶「絞」fオ盃W<E79B83>鏑鑑伺ar〕{R{宵o<E5AEB5>``銃壮Q藁誠汾徑~ォマ訊<EFBE8F>>笈{コA{q套刹d腕ヲ}<7D>吏idncsRhD@ッp喊昧kuqgyィe_7v<37>lpnkl<6B>椛ョ」V梛vゥ浦q<E6B5A6>yo?X<>UssbP{oaGィi`掵ヲ噤葬Nuz搆ォhO梱f;p{yーxb<78>6t梨zxsz淑qz<71>タ<EFBFBD>「ァyコX矧ョ=knyЩmu<6D>チs+jvcShタeyュs埋奪}酢sjT剿nQ麿除Si怛idx揆ノ<E68F86>]bェU槽殷・釦撫<E987A6>tqkャ`s達yxf|Ttmzu∥k<E288A5>ы浙g}ャ}n_享<5F>&L<>ァrtェ<74>r、aRエrノy祝2oyQZ」クゥs<EFBDA9>┃p頻x[V右\抖Bddj_}ooョgTカ身@}YNェqwゥ俳сf━5Ymm|u<>Y}㌻浪Lァ~叙q<E58F99>tkノawoj渓㍉jxo斬x寫エ<E5AFAB>}z。ニ恵m「・`嚆{p孫shp斌<70>X刧~・帳撒Kゥ<4B>嗅劃`YRdN}芸l?W|ャ綰WΜnjRW背л「Zチx万ァ圍h親噫~yl西ljqmク蛎ゥ着コlV<6C>團yg^~^`徃Eff穀c殕L鞄Syァw倉拵笠j}<7D>Yイyh甥、x柤^Z<>佳戎b_V岨n插促qシ学a^ハァ坊RィfC筈㎎<E7AD88>~h錐crArzニlqg_徘団K瀕6V糎[Yq|ww図]e<瓶鋳ヲHIO軒峻ゥ歎ス活Zy-b{<7B><>度<EFBFBD>疹寔oトFqSgnm「}i尋zケサWR[_俵楔フ祷_ec8USM~s]bd撻I密Ff歔浙k楼Oュ織<EFBDAD>ォ鱒zE浚xTモe‘oGkーUeオ哭kR<6B>ラv⑦宙「[祷Id<7F>h妖<68>ャy<EFBDAC>@鋒鯨。tカ匝<EFBDB6>潟j`cjトn<EFBE84>n存jyヶニynu]X讃xmp^昭ヲ准<EFBDA6>ネ島孛ャヤ散<EFBE94>M<7F>Qn沛n<E6B29B>Eu<45>弾om、タッ<EFBE80>ィウ矧捉Z<E68D89>ヲ8庶タマё|<7C><>bstァ|\rY~キ牌<EFBDB7>y<EFBFBD>0}㈲ィm<EFBDA8>抹メ捏用産Wbz<62>Y:ue|ウ棡ィt[Tx<54>殄P|v㎎~<7E>ヲ<7F>]Xク。rk「、燦_エww吹~c屁貫盈ネ枠wZァ「<EFBDA7>ipiゞne詩}S<>Rw寒Ur復宕ie、葺┣hZe~yld=从a^槙キアt<EFBDB1>Xj抽ы酪ウv[n悒<6E>j洶。粋<EFBDA1>.yシ<79>]q孺qj味j<E591B3>T2剞棍姥jzv<76>コ<EFBFBD>yj逐婉|エC}ウ梼r]イ尢ェxィ視bvp<76>等\<5C>{G<>v岑トレbwpイNuqォ労z<E58AB4>轄㌦<E8BD84>ィ尸オィY泪S<E6B3AA>チァe転[{剋~蓉聡IuEo}・ニ|拍ウ<E68B8D>ツ操」/kYnuち<75><E381A1>ッ朧fz冪、-u吐」脹g。Ζ」嫖♂_<E29982>=u:`W客~ア<>bsラィ、PG<50>ォXキOXV嗔杉jI・xuO容昆~sR^[a組S糊]bpy・vyカヤ怐ァ~ャィ孕i答<69>ウ蒲j<E892B2>n罵oKb寥R|G掟lッO迅qヌ重~cU鰐憧|ォWN`U<>?防<C280>Y執、オtヲォ^豫<>do嫉クフ検コWo~資衰「ォgキェpw℡続ぃ惣zw儷b「l。チ丶cmlcミ~~q~ァv~ツr吏<72>W<EFBFBD>r洳T汞ayDe勦ッz・嗇~R」nuYc=緒vf潟q・」<EFBDA5>{イエ輿防杜狽iwwスュ評<EFBDAD><E8A995>ぞv〟・ッonx途Yヲy媛ェ「]垣〕{D尢Ut㊤他qэ`l<>p<EFBFBD><70>f拷Wmja<6A>}ェ憶ュV越|悍敷トox|ャ<>oub<75>}S綱孱w蝕推jl営nsオ縛瑛タzyWClI錨m_ョ|p剥d鋭iーr恬「jo北荘](qツ<71>Wアャ<EFBDB1>剪iho~Hx。_諜j負it<69>Ia<49>x者rwO∟oursn
|
@ -179,14 +179,21 @@ void emscripten_set_main_loop(em_callback_func func, int fps, int simulate_infin
|
|||||||
uint8_t audioBuff[SFG_SFX_SAMPLE_COUNT];
|
uint8_t audioBuff[SFG_SFX_SAMPLE_COUNT];
|
||||||
uint16_t audioPos = 0;
|
uint16_t audioPos = 0;
|
||||||
|
|
||||||
|
static inline uint8_t addSamples(uint8_t sample1, uint8_t sample2)
|
||||||
|
{
|
||||||
|
int16_t mixed = sample1;
|
||||||
|
mixed -= 127;
|
||||||
|
mixed += sample2;
|
||||||
|
mixed = (mixed > 0) ? ((mixed < 255) ? mixed : 255) : 0;
|
||||||
|
return mixed;
|
||||||
|
}
|
||||||
|
|
||||||
void audioFillCallback(void *userdata, uint8_t *s, int l)
|
void audioFillCallback(void *userdata, uint8_t *s, int l)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < l; ++i)
|
for (int i = 0; i < l; ++i)
|
||||||
{
|
{
|
||||||
s[i] = audioBuff[audioPos];
|
s[i] = addSamples(audioBuff[audioPos],SFG_getNextMusicSample());
|
||||||
|
|
||||||
audioBuff[audioPos] = 127;
|
audioBuff[audioPos] = 127;
|
||||||
|
|
||||||
audioPos = (audioPos < SFG_SFX_SAMPLE_COUNT - 1) ? (audioPos + 1) : 0;
|
audioPos = (audioPos < SFG_SFX_SAMPLE_COUNT - 1) ? (audioPos + 1) : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,12 +206,8 @@ void SFG_playSound(uint8_t soundIndex, uint8_t volume)
|
|||||||
|
|
||||||
for (int i = 0; i < SFG_SFX_SAMPLE_COUNT; ++i)
|
for (int i = 0; i < SFG_SFX_SAMPLE_COUNT; ++i)
|
||||||
{
|
{
|
||||||
int16_t mixedValue =
|
audioBuff[pos] =
|
||||||
audioBuff[pos] - 127 + SFG_GET_SFX_SAMPLE(soundIndex,i) * volumeStep;
|
addSamples(audioBuff[pos],SFG_GET_SFX_SAMPLE(soundIndex,i) * volumeStep);
|
||||||
|
|
||||||
mixedValue = (mixedValue > 0) ? ((mixedValue < 255) ? mixedValue : 255) : 0;
|
|
||||||
|
|
||||||
audioBuff[pos] = mixedValue;
|
|
||||||
|
|
||||||
pos = (pos < SFG_SFX_SAMPLE_COUNT - 1) ? (pos + 1) : 0;
|
pos = (pos < SFG_SFX_SAMPLE_COUNT - 1) ? (pos + 1) : 0;
|
||||||
}
|
}
|
||||||
|
78
sounds.h
78
sounds.h
@ -30,6 +30,84 @@
|
|||||||
(SFG_sounds[soundIndex][sampleIndex / 2] >> 4) : \
|
(SFG_sounds[soundIndex][sampleIndex / 2] >> 4) : \
|
||||||
(SFG_sounds[soundIndex][sampleIndex / 2] & 0x0f))
|
(SFG_sounds[soundIndex][sampleIndex / 2] & 0x0f))
|
||||||
|
|
||||||
|
#define SFG_TRACK_SAMPLES (512 * 1024)
|
||||||
|
|
||||||
|
struct
|
||||||
|
{ // all should be initialized to 0
|
||||||
|
uint8_t track;
|
||||||
|
uint32_t t;
|
||||||
|
uint32_t t2;
|
||||||
|
uint32_t n3t;
|
||||||
|
uint32_t n5t;
|
||||||
|
uint32_t n7t;
|
||||||
|
} SFG_MusicState;
|
||||||
|
|
||||||
|
uint8_t SFG_getNextMusicSample()
|
||||||
|
{
|
||||||
|
if (SFG_MusicState.t >= SFG_TRACK_SAMPLES)
|
||||||
|
{
|
||||||
|
SFG_MusicState.track++;
|
||||||
|
|
||||||
|
if (SFG_MusicState.track >= 3)
|
||||||
|
SFG_MusicState.track = 0;
|
||||||
|
|
||||||
|
SFG_MusicState.t = 0;
|
||||||
|
SFG_MusicState.t2 = 0;
|
||||||
|
SFG_MusicState.n3t = 0;
|
||||||
|
SFG_MusicState.n5t = 0;
|
||||||
|
SFG_MusicState.n7t = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t result;
|
||||||
|
|
||||||
|
#define t SFG_MusicState.t
|
||||||
|
#define t2 SFG_MusicState.t2
|
||||||
|
#define n3t SFG_MusicState.n3t
|
||||||
|
|
||||||
|
switch (SFG_MusicState.track)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
uint32_t a = ((t >> 7) | (t >> 9) | (~t << 1) | t);
|
||||||
|
result = ((t) & 65536 ? (a & (((t * t) >> 16) & 0x09)) : ~a);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
result = (t & (3 << (((t >> 10) ^ ((t >> 10) << (t >> 6))))));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
result =
|
||||||
|
((((t >> (t >> 2)) + (t >> (t >> 7)))) & 0x3f | (t >> 5) | (t >> 11))
|
||||||
|
& (t & (32768 | 8192) ? 0xf0 : 0x30);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
result = 127;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef t
|
||||||
|
#undef t2
|
||||||
|
#undef n3t
|
||||||
|
|
||||||
|
SFG_MusicState.t += 1;
|
||||||
|
SFG_MusicState.t2 += SFG_MusicState.t;
|
||||||
|
SFG_MusicState.n3t += 3;
|
||||||
|
SFG_MusicState.n5t += 5;
|
||||||
|
SFG_MusicState.n7t += 7;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
SFG_PROGRAM_MEMORY uint8_t SFG_sounds[][SFG_SFX_SIZE] =
|
SFG_PROGRAM_MEMORY uint8_t SFG_sounds[][SFG_SFX_SIZE] =
|
||||||
{
|
{
|
||||||
{ // 0, bullet shot
|
{ // 0, bullet shot
|
||||||
|
Loading…
Reference in New Issue
Block a user