Hello,

I'm getting back into the APU(one way or another) and am curious about a few things, hoping you can help(yeah you! right there!).

- so i need to know if someone can give a C style algo for generating the waves. I didn't find anything about the square in the docs i've read, but i've read that the triangle is 4-bits wide and behaves like so:

- Now I'm assuming that I can do something infinitely easier for a square, but I don't know the bit-depth or resolution I'm supposed to do it at.

- Same for the noise channel. I can do random no problem, but I don't know if there's a special algorithm to make the randomness accurate to the NES that I should be considering.

Had some more questions, but i forgot them after typing this :p

So anyone have any ideas?

Thanks,

Malik

I'm getting back into the APU(one way or another) and am curious about a few things, hoping you can help(yeah you! right there!).

- so i need to know if someone can give a C style algo for generating the waves. I didn't find anything about the square in the docs i've read, but i've read that the triangle is 4-bits wide and behaves like so:

**Code:**

FEDCBA98765432100123456789ABCDEF

that seems easy enough to create if i have loop that runs at the sample rate i could do this inside:**Code:**

int inc=1; //two global elements

triangle = [-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8]; //outside of the output loop

//...somewhere inside the loop

if(!inc){

for(i=0;i<15; i++){

output = triangle[i];

if(i==15)inc=0;

}

}else{

for(i=15;i>0; i--){

output = triangle[i];

if(i==0)inc=0;

}

}

triangle = [-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8]; //outside of the output loop

//...somewhere inside the loop

if(!inc){

for(i=0;i<15; i++){

output = triangle[i];

if(i==15)inc=0;

}

}else{

for(i=15;i>0; i--){

output = triangle[i];

if(i==0)inc=0;

}

}

- Now I'm assuming that I can do something infinitely easier for a square, but I don't know the bit-depth or resolution I'm supposed to do it at.

- Same for the noise channel. I can do random no problem, but I don't know if there's a special algorithm to make the randomness accurate to the NES that I should be considering.

Had some more questions, but i forgot them after typing this :p

So anyone have any ideas?

Thanks,

Malik