|
Bugs and some errors with recourding code! |
Lucas Adami
Member #8,528
April 2007
|
Hello! I made this code based on this topic: This program records a sound, from your pc input sound...
Here is the bug: - When i write to the file, reading it does not give me the same value it was before, check it on this line when running: printf("In sample: %u In novo: %u\n",*tempbuf,*tempbuf2); A question: - Why i need that interval? And how to get it? Why it need to be calculated and its not a fixed value, like 500? Another question: - What would you do to make this code better? What errors or bugs i did not mentioned before you found? Thx a lot! Cya! |
Kitty Cat
Member #2,815
October 2002
|
Lucas Adami
Member #8,528
April 2007
|
Its because i am using visual c++ express, so there is a new function with the _s, i will try to use the rewind thx! - Why i need that interval? And how to get it? Why it need to be calculated and its not a fixed value, like 500? - How to write to file and make it a VALID .wav format? TY! |
Kitty Cat
Member #2,815
October 2002
|
Quote: Its because i am using visual c++ express, so there is a new function with the _s VC++ has fopen and fscanf, however only newer versions of VC++ have fopen_s and fscanf_s.. no other compiler or OS does. Quote: - Why i need that interval? And how to get it? Why it need to be calculated and its not a fixed value, like 500? It should work as a fixed value, but the interval value helps to make it so you get back when enough data is ready. Quote: How to write to file and make it a VALID .wav format? -- |
Lucas Adami
Member #8,528
April 2007
|
Ty but its returning an error! At this function: if(save_sample("test.wav",sample)!=0) printf("ERROR!"); Why its returning an error? Omg what a headake!!!!!!!! |
Kitty Cat
Member #2,815
October 2002
|
Sorry, it appears Allegro doesn't fully implement that yet. Here's something that should work:
Note that I haven't tested it or even tried to compile it, but hopefully will work with few changes needed. -- |
Lucas Adami
Member #8,528
April 2007
|
Well, it didnt worked fine, so i wrote everything in a text file, then i read it and put in a sample , but the file its getting too big! How i could minimize that? Code: To read: fscanf_s(fp,"%d %d %d",&bitcap,&ratecap,&size); sample = create_sample(bitcap, 0, ratecap, size); while(!feof(fp)) { fscanf_s(fp,"%u ",buf); buf++; } In a simple 5 seconds of recording the file gets around 1.5 MB :S Ty for attention, hope you can help me in this problem! Cya! |
Kitty Cat
Member #2,815
October 2002
|
Quote: Well, it didnt worked fine What was the problem with it? Quote: , so i wrote everything in a text file, then i read it and put in a sample , but the file its getting too big! How i could minimize that? You're converting them to ascii numbers. Leave them as normal pcm data:
Note that this will create files that only your program read. Nothing else will be able to load it. Also not that it will still cause somewhat large files since it's uncompressed data. -- |
Lucas Adami
Member #8,528
April 2007
|
Hello again! Omg! Can you help me with that? Ty! EDITED---------------- By my way writing in charr worked now, after debugging a lot i found that some chars where considered '\n' or something like that! So i used now binary files and it worked fine! The file is now about 200kb for 5 sec! It reduced a lot How to compress data? Ty! |
Kitty Cat
Member #2,815
October 2002
|
Quote: By your way of making an wav file, when you load it the sound quality decreases 10x! Hmm, woops. That one part should be... pack_iputw(spl->bits*(spl->stereo?2:1)/8, pf); pack_iputl(spl->bits*(spl->stereo?2:1)/8*spl->freq, pf); pack_iputw(spl->bits, pf); (change that one '16' to 'spl->bits'). Quote: How to compress data? Ty! Use something like oggdropXPd to compress it as an Ogg, then use AlOgg or APEG to play it in Allegro. -- |
Lucas Adami
Member #8,528
April 2007
|
Ty a lot, but i have some strange ting, not a problem, i get the sound save it in the file, when i play it there is something strange in the end of it, the sound make a 'stop recording' sound, then pass more 3 sec and then another 'stop recording' sound! Very strange, do you see (or hear ;p) something strange? Ty!Cya! |
|