• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
lomateron

big loop with big array

10 posts in this topic

I have this big array and this big {for} loop to fill this array
the loop reads a soundfile, and writes it to the array, the sound data is simple, 3minutes of 10hz constant
so the sound data should be something that starts 0,1,2,3,4,...65534 then goes down and up and down again and again

but debuggin i found that when it gets aproximately to the 200 loop the data that reads will stay the same so it will fill the array with the same value from that point until it finishes loop. the soundfile can be changed to another music that has same format and the same happens, why?

[source lang="cpp"] D3DXVECTOR4 dd[7935489]; //the big array, it is located up in the head of the program.


//Data of sound
BYTE id[40];
unsigned int ivb;
unsigned short p1[2]; //right and left 1
unsigned short p2[2]; //right and left 2

FILE * fp;
fp = fopen("12.wav","r");

fread(id,sizeof(BYTE),40,fp);//read unessesary info of sound
fread(&ivb,sizeof(unsigned int),1,fp);// read the sized of the data
unsigned int ss= ivb/4;// calculate num of samples
unsigned int i;
for(i=0;i < (ss/2);i++)//fill part of the array with all sound data
{
fread(p1,sizeof(unsigned short),2,fp);
fread(p2,sizeof(unsigned short),2,fp);
dd[i]=D3DXVECTOR4(float(p1[0]),float(p1[1]),float(p2[0]),float(p2[1]));
}[/source] Edited by lomateron
0

Share this post


Link to post
Share on other sites
does it looks complex?,its simple man,if you know about how to make soundfiles, but i want to know if someone had that same problem.
with just that code and a soundfile,16 bits 2channels 44100samples/second, you can try it yourself and see.

and yes i just wasted like a day to get to this. I created code that was based on that array so i had to recheck it, it took me time...like a day Edited by lomateron
0

Share this post


Link to post
Share on other sites
[quote name='jeroenb' timestamp='1340715034' post='4952992']
I would also suggest to open the file as binary ("rb").
[/quote]
This is most likely it. Opening a binary file as text can cause [i]interesting[/i] things to happen, such as data read being interpreted differently.
0

Share this post


Link to post
Share on other sites
well the variables are initialized the same way you can see them in the code

[left][background=rgb(250, 251, 252)]reading past the end--nop because the loop is around 2 million times and the data starts to get repeated at the 220 loop[/background][/left]


the problem isn't in the soundfile, i had opened it([url="http://ie.microsoft.com/testdrive/HTML5/TypedArrays/"]http://ie.microsoft....L5/TypedArrays/[/url]),i have played it too ,and i have opened with that code other soundfiles and at some point near the start the array starts to be filled with the same data until loop finishes. Edited by lomateron
0

Share this post


Link to post
Share on other sites
My first guess would be that the value of ivb is being read wrong?

Put a breakpoint on the for loop and make a note of the variables.

On other words, you need to make sure (ss/2) is the expected size for your data. Edited by mark ds
0

Share this post


Link to post
Share on other sites
I'm going to ask you a series of questions, and I want you to give specific and detailed answers:[list]
[*]Did you do what jeroenb suggested and open the file as a binary file (as "rb") (you should be doing this anyway, even if your problem persists)?
[*]Are you checking the status of the file with [url="http://www.cplusplus.com/reference/clibrary/cstdio/ferror/"]ferror[/url] and [url="http://www.cplusplus.com/reference/clibrary/cstdio/feof/"]feof[/url]?
[*]Are you sure [url="http://www.cplusplus.com/reference/clibrary/cstdio/fread/"]fread[/url] is reading the requested number of bytes (it can read fewer than requested)?
[*]Are you 100% sure this is a 16-bit, 2 channel PCM WAV file?
[*]Have you properly read the "unnecessary info of sound" and verified that you're getting what you expect in the header?
[*]Is ivb == size of the file in bytes - 44?
[/list]

Also, 16 bit PCM WAV files use signed numbers (you should be using [font=courier new,courier,monospace]short[/font]), not unsigned numbers (you shouldn't be using [font=courier new,courier,monospace]unsigned short[/font]) (you'll get the wrong values). And [font=courier new,courier,monospace]sizeof(BYTE)[/font] isn't intuitive, as a [font=courier new,courier,monospace]BYTE[/font] should always have a size of 1 (and if it's more than that for some broken reason, you'll read too much and go past the header). Edited by Cornstalks
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0