< September 28 | Computing desk archive | September 30 > |
---|
| ||||||||
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions at one of the pages linked to above. | ||||||||
|
I've just gotten a new 30GB movie iPod, and I'm so excited! But I've received a lot of different comments about how often I should charge it. One person told me that I should let the battery drain all of the way to dead before charging it, and the other said that the iPod should be charged a lot so it always has some charge. What's the better idea? I've heard a lot more about the drain-it-all idea, but the person who constantly charged her iPod said she still has the same iPod from two and a half years ago and it works great. The ikiroid ( talk· desk· Advise me) 00:28, 29 September 2006 (UTC)
Ah, so I shouldn't drain it, according to the article. OK, thank you Canley. The ikiroid ( talk· desk· Advise me) 19:31, 29 September 2006 (UTC)
I have been considering joining a BitTorrent project lately, but a question has come up that the project in question's FAQ that seems to be neatly avoided. Is BitTorrent file sharing legal, or not? I am under the impression now that it is legal as long as you do not sell the product, but I don't know. It would be nice to know the legality of BitTorrent before I engage in any activity with it. Thank you! PullToOpen talk 00:57, 29 September 2006 (UTC)
What sort of project do you mean? If you plan to help develop a Bittorrent client, such as uTorrent, that's perfectly legal. If you plan to help organise and maintain a Bittorrent tracker, such as Suprnova or Mininova, you may end up facing prosecution or at least the threat of prosecution.
My system clock in Windows 2000 is one our late . I set it properly but the next day the same story. I do not have the "Automatically adjust clock for daylight saving changes" option enabled
What could be the problem?
Thank you
try making sure you have the right time zone.
A computer here worked fine on Monday. It sat idle all week (but did have Windows Auto-Update running). Now, it will not accept any USB thumbdrives. Was there a MS patch this week that restricts USB access? -- Kainaw (talk) 14:02, 29 September 2006 (UTC)
If I have a bulky computer that I don't want to transport for study in another country, is there a set up that I could acheive to allow me to access data on my harddrives (if have five to total 800 GB so transport of data/drives not really practical) from a laptop in another country? -- Username132 ( talk) 15:58, 29 September 2006 (UTC)
While sending emails to many people at once I use one of the receipients' address in the "To" field and other addresses on "BCC" field.Is there any way to send mails to different people so that the receipient may think that that mail is specially sent to him and not to others.Here i mean to say that in some cases in place of eg "Dear John" can i insert the receipients' name as a field eg "Dear {Receipient}.May be i could not put the matter exactly.Thanks
What does "64-bit" mean in the context of describing a video card? Surely the N64 didn't have more than 4GB of dedicated video memory.. why else use 64 bit wide registers if not to hold memory addresses 64 bits long? -- froth T C 19:28, 29 September 2006 (UTC)
It's not only about having 64 bits to hold memory registers, remember a CPU/GPU is more than just a fancy switchboard (at times). More important to the N64 was the size of it's video processor, which was also 64 bits, and the MOST important was the width of the video bus which was 128 bits. An increased register size can make SIMD possible (for the cpu and gpu) at a low level, along with other math-intensive functions which are important to good graphic systems. They even touch on why strictly using a 64 bit cpu is bad for consoles, in Nintendo 64#Trivia.-- Jmeden2000 20:19, 29 September 2006 (UTC)
You might be confusing the data bus with the address bus. IIRC, the data bus is how much data can move in/out of the processor in a cycle, while the address bus limits the amount of memory in the system. -- Bennybp 21:34, 29 September 2006 (UTC)
The article on 64-bit shows that the term is pretty ambiguous. It looks like the term can either refer to the width of the various buses, or the size of some data types. IE a 64-bit data type can hold bigger values (2^64 possible values). I'm not positive what the 64 in N64 really meant, but from the N64 article (trivia section) it does look like it refers to the data type sizes, and that the buses are 32-bit. -- 74.69.54.30 20:15, 1 October 2006 (UTC)
I've recently become interested in computer security.. one of the kinds of attacks I've read about is the buffer overflow attack. The attacker writes more than the allocated space for a variable so the input spills over possibly into code that's about to be executed. This allows the attacker to overwrite that code with code of his own, and this is called being able to execute arbitrary code on the target machine. Now what I'm confused about is that "running arbitrary code" is automatically associated with gaining root permissions. What about users on a *nix system that can execute any code that they want without any kind of fancy attack at all? In other words it seems like there should be a very difficult step between "running arbitrary code" and "gaining root permissions" but you never hear about that.
One idea that just occured to me is that maybe if the program you're attacking is running as root then your code will have root priviliges as well, but users can't execute any code as root. Is this correct or is was my original question valid? -- froth T C 19:56, 29 September 2006 (UTC)
There is, indeed, a Unix COMMAND that gives the user root permissions; sudo is its name. It can be called from a shell script as well. After authentication via an admin password, for a default of 5 minutes, the user may use sudo again to run commands as root. For instance:
sudo nano /var/etc/thefileiwanttoedit.txt
would edit the file mentioned as root, thus giving total control over that file. Furthermore, in regards to installation of programs, programs installed via sudo make (insert parameters here) would give thre program root permissions.
Hope this helped ;-) Bellito 19:57, 22 October 2006 (UTC)
Has there been any move to make HTML or MediaWiki tables where the cells are grouped by column, or not at all, rather than by row? This could (a) make it easier to shift cells down, when editing a table manually; and (b) tell screen readers to read the table sideways. It seems to me this could be done in two ways in HTML, if the standard were changed appropriately:
<table> <tcol> <!-- The current tcol is for formatting only, and doesn't allow any children --> <th> Column 1 Row 1 </th> <td> Column 1 Row 2 </td> <td> Column 1 Row 3 </td> </tcol> <tcol> <th> Column 2 Row 1 </th> <td> Column 2 Row 2 </td> <td> Column 2 Row 3 </td> </tcol> </table>
<table rows=3 cols=2> <th row=1 col=1> Column 1 Row 1 </th> <td row=2 col=1> Column 1 Row 2 </td> <td row=3 col=1> Column 1 Row 3 </td> <th row=1 col=2> Column 2 Row 1 </th> <td row=2 col=2> Column 2 Row 2 </td> <td row=3 col=2> Column 2 Row 3 </td> </table>
Neon Merlin 22:30, 29 September 2006 (UTC)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>DMCI Game Development Club</title> <link rel="stylesheet" href="default.css"> </head> <body> <table cellspacing="0px" cellpadding="0px" align="center" class="header"> <tr> <td colspan=5><h1>DMCI Game Development Club</h1></td> </tr> <tr> <td class="tab"><img src="interface_images/tab.gif" class="tab" /><div class="tab">Active Tab</div></td> <td class="tab"><img src="interface_images/inactivetab.gif" class="tab" /><div class="tab">Other Tab 1</div></td> <td class="tab"><img src="interface_images/inactivetab.gif" class="tab" /><div class="tab">Other Tab 2</div></td> <td class="tab"><img src="interface_images/inactivetab.gif" class="tab" /><div class="tab">Other Tab 3</div></td> <td class="tab"><img src="interface_images/inactivetab.gif" class="tab" /><div class="tab">Other Tab 4</div></td> </tr> </table><table cellspacing="0px" cellpadding="0px" align="center" class="main"><tr> <td class="hborder"><img src="interface_images/borderleft.gif" class="hborder"></td> <td class="textpanel"> <h2>Welcome!</h2> <p>This is your main panel. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </td> <td class="hborder"><img src="interface_images/borderright.gif" class="hborder"></td></tr> <tr><td class="cborder"><img src="interface_images/borderbottomleft.gif" class="cborder"></td> <td class="vborder"><img src="interface_images/borderbottom.gif" class="vborder"></td> <td class="cborder"><img src="interface_images/borderbottomright.gif" class="cborder"></td></tr> </table> </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252"> <TITLE>DMCI Game Development Club</TITLE> <META NAME="GENERATOR" CONTENT="OpenOffice.org 2.0 (Win32)"> <META NAME="CREATED" CONTENT="20060930;12015804"> <META NAME="CHANGED" CONTENT="16010101;0"> <STYLE> <!-- TD P { margin-bottom: 0cm } H1 { text-align: center } --> </STYLE> </HEAD> <BODY LANG="en-GB" BACKGROUND="interface_images/background.gif" DIR="LTR"> <CENTER> <TABLE CELLPADDING=0 CELLSPACING=0 STYLE="page-break-before: always"> <TR> <TD COLSPAN=5> <H1>DMCI Game Development Club</H1> </TD> </TR> <TR> <TD> <P><IMG SRC="interface_images/tab.gif" NAME="graphics1" ALIGN=BOTTOM WIDTH=120 HEIGHT=30 BORDER=0></P> <P>Active Tab</P> </TD> <TD> <P><IMG SRC="interface_images/inactivetab.gif" NAME="graphics2" ALIGN=BOTTOM WIDTH=120 HEIGHT=30 BORDER=0></P> <P>Other Tab 1</P> </TD> <TD> <P><IMG SRC="interface_images/inactivetab.gif" NAME="graphics3" ALIGN=BOTTOM WIDTH=120 HEIGHT=30 BORDER=0></P> <P>Other Tab 2</P> </TD> <TD> <P><IMG SRC="interface_images/inactivetab.gif" NAME="graphics4" ALIGN=BOTTOM WIDTH=120 HEIGHT=30 BORDER=0></P> <P>Other Tab 3</P> </TD> <TD> <P><IMG SRC="interface_images/inactivetab.gif" NAME="graphics5" ALIGN=BOTTOM WIDTH=120 HEIGHT=30 BORDER=0></P> <P>Other Tab 4</P> </TD> </TR> </TABLE> </CENTER> <CENTER> <TABLE CELLPADDING=0 CELLSPACING=0> <TR> <TD BGCOLOR="#eeddcc"> <P><IMG SRC="interface_images/borderleft.gif" NAME="graphics6" ALIGN=BOTTOM WIDTH=15 HEIGHT=1 BORDER=0></P> </TD> <TD BGCOLOR="#eeddcc"> <H2>Welcome!</H2> <P STYLE="margin-bottom: 0.5cm">This is your main panel. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</P> <P>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</P> </TD> <TD BGCOLOR="#eeddcc"> <P><IMG SRC="interface_images/borderright.gif" NAME="graphics7" ALIGN=BOTTOM WIDTH=15 HEIGHT=1 BORDER=0></P> </TD> </TR> <TR> <TD BGCOLOR="#eeddcc"> <P><IMG SRC="interface_images/borderbottomleft.gif" NAME="graphics8" ALIGN=BOTTOM WIDTH=15 HEIGHT=15 BORDER=0></P> </TD> <TD BGCOLOR="#eeddcc"> <P><IMG SRC="interface_images/borderbottom.gif" NAME="graphics9" ALIGN=BOTTOM WIDTH=1 HEIGHT=15 BORDER=0></P> </TD> <TD BGCOLOR="#eeddcc"> <P><IMG SRC="interface_images/borderbottomright.gif" NAME="graphics10" ALIGN=BOTTOM WIDTH=15 HEIGHT=15 BORDER=0></P> </TD> </TR> </TABLE> </CENTER> <P><BR><BR> </P> </BODY> </HTML>
<table> <tr> <td>top left</td> <td>top right</td> </tr> <tr> <td>bottom left</td> <td>bottom right</td> </tr> </table>
<table> <tr> <td>top left</td> <td>top right</td> </tr> <tr> <td>bottom left</td> <td>bottom right</td> </tr> </table>
I'm interested in coding a program (in C\C++ or Python) for some low-level audio control in Windows. What I mean is, I want to deal with the actual samples from the stereo output. I don't want to import sound files or anything like that, I just want to output audio based on direct manipulation of samples, which is what this program should do. Example, I want to be able to play a 440 Hz sine wave sound by just writing samples following the sine function over time (using the sample rate and the frequency to get the said 440 Hz)
Any suggestions on where to start? I'm not very experienced in either C\C++ or Python, but I just need a few complex and interesting projects to push my skills further. Thanks! - L.
/dev/dsp
sound interface (which, incidentally, works fine in
cygwin). Apart from the audio-device stuff there's just some very basic stuff that builds a waveform from the sine function before playing it. The code is a little more complicated than you absolutely basically need, as it has a simple
envelope which fades the volume in and out for each note (without this you hear a nasty click at the beginning and end).
/*
playwave.c
Copyright (c) 2005 W. Finlay McWalter
Licence: your choice of GPL, GFDL, or CCbySA
Plays a given tone for a brief period of time, using the system's /dev/dsp
interface. Tested using cygwin (should work on linux too).
Version history:
v1. Basic version
v2. Adds simple envelope (attack and release) to avoid nasty clicks
between notes
v3. Change to 16 bit signed (LE) output (wow, so much better), and
make envelope code more programmable.
Notes:
- Current build produces signed 16 bit 44100 Hz mono little endian raw PCM
- Samples are appended to a file called "./outfile". This allows importing
the data into audacity and listening to it without the gaps imposed
by multiple invocations of the program.
Help on tone arithmetic: http://en.wikipedia.org/wiki/Physics_of_music
Programming notes:
http://www.oreilly.de/catalog/multilinux/excerpt/ch14-05.htm
http://davmac.org/davpage/linux/linux-sound.html
http://www.4front-tech.com/pguide/audio.html
Sample invocation (close encounters):
rm outfile ; touch outfile ; ./playwave 440 10000 ; ./playwave 495 10000 ;
./playwave 392 10000 ; ./playwave 196 10000 ; ./playwave 294 10000
*/
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/soundcard.h>
#include <math.h>
#define CHANNELS 1
#define RATE 44100 /* samples/sec */
#define LENGTH 0.8f /* seconds */
#define SIZE 2 /* bytes per sample */
#define NUM_SAMPLES_PER_BUFFER ((int)(LENGTH*RATE*SIZE*CHANNELS)/2)
// ENVELOPE FRACTION defines the proportion of the sample buffer that
// is shaped by the envelope function. So to shape the beginning and
// ending 10th, set envelope fraction to 10. ENVELOPE_FRACTION must
// be an integer.
#define ENVELOPE_FRACTION 3
int main (int argc, char** argv){
int audioDevice;
int outfile;
int status;
unsigned int arg;
int counter;
int x;
float angle;
int num_samples_in_waveform;
float volume = 6.0f;
signed short buf[NUM_SAMPLES_PER_BUFFER];
int freq = 440;
float value;
float vol_multiplier;
if (argc != 3){
fprintf(stderr, "usage: playwave <frequency> <volume>");
exit(1);
}
freq = atof(argv[1]);
volume = atof(argv[2]);
/* compute waveform */
num_samples_in_waveform = RATE/freq;
for (x=0; x< NUM_SAMPLES_PER_BUFFER; x++){
angle = (2.0f * 3.14159f * (float)x) / (float)num_samples_in_waveform;
value = sin(angle);
vol_multiplier = 1.0f;
// envelope: lead in
if(x < (NUM_SAMPLES_PER_BUFFER/ENVELOPE_FRACTION)){
vol_multiplier = (ENVELOPE_FRACTION * (float)x) / ((float)NUM_SAMPLES_PER_BUFFER) ;
}
// envelope: lead out
if(x > ((ENVELOPE_FRACTION-1)*NUM_SAMPLES_PER_BUFFER)/ENVELOPE_FRACTION){
vol_multiplier = (ENVELOPE_FRACTION * (NUM_SAMPLES_PER_BUFFER-x)) / ((float)NUM_SAMPLES_PER_BUFFER) ;
}
buf[x] = (signed short)(volume * value * vol_multiplier);
}
outfile = open("outfile", O_RDWR|O_APPEND|O_CREAT);
if (outfile < 0) {
perror("open of opening outfile failed");
exit(1);
}
status = write(outfile, buf, sizeof(buf));
if (status != sizeof(buf))
perror("wrote wrong number of bytes");
close(outfile);
// Now write that out to the audio device
/* open sound device */
audioDevice = open("/dev/dsp", O_RDWR);
if (audioDevice < 0) {
perror("open of /dev/dsp failed");
exit(1);
}
/* set format */
arg = AFMT_S16_LE;
status = ioctl(audioDevice, SNDCTL_DSP_SETFMT, &arg);
if (status == -1) {
perror("SNDCTL_DSP_SETFMT");
exit(1);
}
arg = CHANNELS; /* mono or stereo */
status = ioctl(audioDevice, SOUND_PCM_WRITE_CHANNELS, &arg);
if (status == -1)
perror("SOUND_PCM_WRITE_CHANNELS ioctl failed");
if (arg != CHANNELS)
perror("unable to set number of channels");
arg = RATE; /* sampling rate */
status = ioctl(audioDevice, SOUND_PCM_WRITE_RATE, &arg);
if (status == -1)
perror("SOUND_PCM_WRITE_WRITE ioctl failed");
status = write(audioDevice, buf, sizeof(buf));
if (status != sizeof(buf))
perror("wrote wrong number of bytes");
/* wait for playback to complete before recording again */
status = ioctl(audioDevice, SOUND_PCM_SYNC, 0);
if (status == -1)
perror("SOUND_PCM_SYNC ioctl failed");
close(audioDevice);
}
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void SineGen(float step, int length, FILE *fp);
void NoiseGen(int length, FILE *fp);
void SquareGen(float step, int length, FILE *fp);
#define PI 3.14159265
#define S_RATE 44100 // Sample rate
#define B_RATE 32768 // Bit rate (16 bits = 2^16 / 2 = 32768)
int main()
{
short unsigned int choice;
unsigned int length;
float freq, step;
do
{
printf("\nEnter frequency: ");
scanf("%f", &freq);
if (freq < 1)
{
printf("Incorrect frequency.");
continue;
}
printf("\nEnter length: ");
scanf("%i", &length);
if (length < 1)
{
printf("Incorrect length.");
continue;
}
printf("\n1. Sine wave\n2. White noise\n3. Square wave\n\nChoice? ");
scanf("%i", &choice);
if (choice < 1 || choice > 3)
{
printf("Bad choice.");
continue;
}
}
while(freq < 1 && length < 1 && choice < 1 || choice > 3);
step = (freq / S_RATE); // Converts frequency (Hz) into step size.
FILE *fp;
fp = fopen("wave.raw", "w"); // Open the file, and write.
switch (choice)
{
case 1: SineGen(step, length, fp); break;
case 2: NoiseGen(length, fp); break;
case 3: SquareGen(step, length, fp);
default: break;
}
fclose(fp); // File written, close.
getch();
return 0;
}
void SineGen(float step, int length, FILE *fp)
{
int j;
float sample, i;
step *= 360;
for (j = 0; j < length; ++j)
for (i = 0; i < 360; i += step) // The pitch is raised by increasing the step size.
{
sample = (sin(i * PI / 180)) * B_RATE; // Convert degrees to radians for sin(), scale float to correct amplitude.
fprintf(fp, "%i\t", (int) sample); // Cast to int for correct parsing by wave editor.
printf("%i\t", (int) sample); // Display as integers.
}
}
void NoiseGen(int length, FILE *fp)
{
srand((unsigned)time(NULL)); // Uses system clock as inital seed.
int j, randsamp;
for (j = 0; j < length; ++j)
{
randsamp = ((B_RATE * 2) * rand() / RAND_MAX) - B_RATE; // Generates random number between -B_RATE to B_RATE.
fprintf(fp, "%i\t", randsamp);
printf("%i\t", randsamp);
}
}
void SquareGen(float step, int length, FILE *fp)
{
int j;
float i;
step = 1 / step;
for (j = 0; j < length; ++j)
{
for (i = 0; i < step; ++i)
{
fprintf(fp, "%i\t", -B_RATE);
printf("%i\t", -B_RATE);
}
for (i = 0; i < step; ++i)
{
fprintf(fp, "%i\t", B_RATE);
printf("%i\t", B_RATE);
}
}
}
< September 28 | Computing desk archive | September 30 > |
---|
| ||||||||
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions at one of the pages linked to above. | ||||||||
|
I've just gotten a new 30GB movie iPod, and I'm so excited! But I've received a lot of different comments about how often I should charge it. One person told me that I should let the battery drain all of the way to dead before charging it, and the other said that the iPod should be charged a lot so it always has some charge. What's the better idea? I've heard a lot more about the drain-it-all idea, but the person who constantly charged her iPod said she still has the same iPod from two and a half years ago and it works great. The ikiroid ( talk· desk· Advise me) 00:28, 29 September 2006 (UTC)
Ah, so I shouldn't drain it, according to the article. OK, thank you Canley. The ikiroid ( talk· desk· Advise me) 19:31, 29 September 2006 (UTC)
I have been considering joining a BitTorrent project lately, but a question has come up that the project in question's FAQ that seems to be neatly avoided. Is BitTorrent file sharing legal, or not? I am under the impression now that it is legal as long as you do not sell the product, but I don't know. It would be nice to know the legality of BitTorrent before I engage in any activity with it. Thank you! PullToOpen talk 00:57, 29 September 2006 (UTC)
What sort of project do you mean? If you plan to help develop a Bittorrent client, such as uTorrent, that's perfectly legal. If you plan to help organise and maintain a Bittorrent tracker, such as Suprnova or Mininova, you may end up facing prosecution or at least the threat of prosecution.
My system clock in Windows 2000 is one our late . I set it properly but the next day the same story. I do not have the "Automatically adjust clock for daylight saving changes" option enabled
What could be the problem?
Thank you
try making sure you have the right time zone.
A computer here worked fine on Monday. It sat idle all week (but did have Windows Auto-Update running). Now, it will not accept any USB thumbdrives. Was there a MS patch this week that restricts USB access? -- Kainaw (talk) 14:02, 29 September 2006 (UTC)
If I have a bulky computer that I don't want to transport for study in another country, is there a set up that I could acheive to allow me to access data on my harddrives (if have five to total 800 GB so transport of data/drives not really practical) from a laptop in another country? -- Username132 ( talk) 15:58, 29 September 2006 (UTC)
While sending emails to many people at once I use one of the receipients' address in the "To" field and other addresses on "BCC" field.Is there any way to send mails to different people so that the receipient may think that that mail is specially sent to him and not to others.Here i mean to say that in some cases in place of eg "Dear John" can i insert the receipients' name as a field eg "Dear {Receipient}.May be i could not put the matter exactly.Thanks
What does "64-bit" mean in the context of describing a video card? Surely the N64 didn't have more than 4GB of dedicated video memory.. why else use 64 bit wide registers if not to hold memory addresses 64 bits long? -- froth T C 19:28, 29 September 2006 (UTC)
It's not only about having 64 bits to hold memory registers, remember a CPU/GPU is more than just a fancy switchboard (at times). More important to the N64 was the size of it's video processor, which was also 64 bits, and the MOST important was the width of the video bus which was 128 bits. An increased register size can make SIMD possible (for the cpu and gpu) at a low level, along with other math-intensive functions which are important to good graphic systems. They even touch on why strictly using a 64 bit cpu is bad for consoles, in Nintendo 64#Trivia.-- Jmeden2000 20:19, 29 September 2006 (UTC)
You might be confusing the data bus with the address bus. IIRC, the data bus is how much data can move in/out of the processor in a cycle, while the address bus limits the amount of memory in the system. -- Bennybp 21:34, 29 September 2006 (UTC)
The article on 64-bit shows that the term is pretty ambiguous. It looks like the term can either refer to the width of the various buses, or the size of some data types. IE a 64-bit data type can hold bigger values (2^64 possible values). I'm not positive what the 64 in N64 really meant, but from the N64 article (trivia section) it does look like it refers to the data type sizes, and that the buses are 32-bit. -- 74.69.54.30 20:15, 1 October 2006 (UTC)
I've recently become interested in computer security.. one of the kinds of attacks I've read about is the buffer overflow attack. The attacker writes more than the allocated space for a variable so the input spills over possibly into code that's about to be executed. This allows the attacker to overwrite that code with code of his own, and this is called being able to execute arbitrary code on the target machine. Now what I'm confused about is that "running arbitrary code" is automatically associated with gaining root permissions. What about users on a *nix system that can execute any code that they want without any kind of fancy attack at all? In other words it seems like there should be a very difficult step between "running arbitrary code" and "gaining root permissions" but you never hear about that.
One idea that just occured to me is that maybe if the program you're attacking is running as root then your code will have root priviliges as well, but users can't execute any code as root. Is this correct or is was my original question valid? -- froth T C 19:56, 29 September 2006 (UTC)
There is, indeed, a Unix COMMAND that gives the user root permissions; sudo is its name. It can be called from a shell script as well. After authentication via an admin password, for a default of 5 minutes, the user may use sudo again to run commands as root. For instance:
sudo nano /var/etc/thefileiwanttoedit.txt
would edit the file mentioned as root, thus giving total control over that file. Furthermore, in regards to installation of programs, programs installed via sudo make (insert parameters here) would give thre program root permissions.
Hope this helped ;-) Bellito 19:57, 22 October 2006 (UTC)
Has there been any move to make HTML or MediaWiki tables where the cells are grouped by column, or not at all, rather than by row? This could (a) make it easier to shift cells down, when editing a table manually; and (b) tell screen readers to read the table sideways. It seems to me this could be done in two ways in HTML, if the standard were changed appropriately:
<table> <tcol> <!-- The current tcol is for formatting only, and doesn't allow any children --> <th> Column 1 Row 1 </th> <td> Column 1 Row 2 </td> <td> Column 1 Row 3 </td> </tcol> <tcol> <th> Column 2 Row 1 </th> <td> Column 2 Row 2 </td> <td> Column 2 Row 3 </td> </tcol> </table>
<table rows=3 cols=2> <th row=1 col=1> Column 1 Row 1 </th> <td row=2 col=1> Column 1 Row 2 </td> <td row=3 col=1> Column 1 Row 3 </td> <th row=1 col=2> Column 2 Row 1 </th> <td row=2 col=2> Column 2 Row 2 </td> <td row=3 col=2> Column 2 Row 3 </td> </table>
Neon Merlin 22:30, 29 September 2006 (UTC)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>DMCI Game Development Club</title> <link rel="stylesheet" href="default.css"> </head> <body> <table cellspacing="0px" cellpadding="0px" align="center" class="header"> <tr> <td colspan=5><h1>DMCI Game Development Club</h1></td> </tr> <tr> <td class="tab"><img src="interface_images/tab.gif" class="tab" /><div class="tab">Active Tab</div></td> <td class="tab"><img src="interface_images/inactivetab.gif" class="tab" /><div class="tab">Other Tab 1</div></td> <td class="tab"><img src="interface_images/inactivetab.gif" class="tab" /><div class="tab">Other Tab 2</div></td> <td class="tab"><img src="interface_images/inactivetab.gif" class="tab" /><div class="tab">Other Tab 3</div></td> <td class="tab"><img src="interface_images/inactivetab.gif" class="tab" /><div class="tab">Other Tab 4</div></td> </tr> </table><table cellspacing="0px" cellpadding="0px" align="center" class="main"><tr> <td class="hborder"><img src="interface_images/borderleft.gif" class="hborder"></td> <td class="textpanel"> <h2>Welcome!</h2> <p>This is your main panel. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </td> <td class="hborder"><img src="interface_images/borderright.gif" class="hborder"></td></tr> <tr><td class="cborder"><img src="interface_images/borderbottomleft.gif" class="cborder"></td> <td class="vborder"><img src="interface_images/borderbottom.gif" class="vborder"></td> <td class="cborder"><img src="interface_images/borderbottomright.gif" class="cborder"></td></tr> </table> </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252"> <TITLE>DMCI Game Development Club</TITLE> <META NAME="GENERATOR" CONTENT="OpenOffice.org 2.0 (Win32)"> <META NAME="CREATED" CONTENT="20060930;12015804"> <META NAME="CHANGED" CONTENT="16010101;0"> <STYLE> <!-- TD P { margin-bottom: 0cm } H1 { text-align: center } --> </STYLE> </HEAD> <BODY LANG="en-GB" BACKGROUND="interface_images/background.gif" DIR="LTR"> <CENTER> <TABLE CELLPADDING=0 CELLSPACING=0 STYLE="page-break-before: always"> <TR> <TD COLSPAN=5> <H1>DMCI Game Development Club</H1> </TD> </TR> <TR> <TD> <P><IMG SRC="interface_images/tab.gif" NAME="graphics1" ALIGN=BOTTOM WIDTH=120 HEIGHT=30 BORDER=0></P> <P>Active Tab</P> </TD> <TD> <P><IMG SRC="interface_images/inactivetab.gif" NAME="graphics2" ALIGN=BOTTOM WIDTH=120 HEIGHT=30 BORDER=0></P> <P>Other Tab 1</P> </TD> <TD> <P><IMG SRC="interface_images/inactivetab.gif" NAME="graphics3" ALIGN=BOTTOM WIDTH=120 HEIGHT=30 BORDER=0></P> <P>Other Tab 2</P> </TD> <TD> <P><IMG SRC="interface_images/inactivetab.gif" NAME="graphics4" ALIGN=BOTTOM WIDTH=120 HEIGHT=30 BORDER=0></P> <P>Other Tab 3</P> </TD> <TD> <P><IMG SRC="interface_images/inactivetab.gif" NAME="graphics5" ALIGN=BOTTOM WIDTH=120 HEIGHT=30 BORDER=0></P> <P>Other Tab 4</P> </TD> </TR> </TABLE> </CENTER> <CENTER> <TABLE CELLPADDING=0 CELLSPACING=0> <TR> <TD BGCOLOR="#eeddcc"> <P><IMG SRC="interface_images/borderleft.gif" NAME="graphics6" ALIGN=BOTTOM WIDTH=15 HEIGHT=1 BORDER=0></P> </TD> <TD BGCOLOR="#eeddcc"> <H2>Welcome!</H2> <P STYLE="margin-bottom: 0.5cm">This is your main panel. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</P> <P>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</P> </TD> <TD BGCOLOR="#eeddcc"> <P><IMG SRC="interface_images/borderright.gif" NAME="graphics7" ALIGN=BOTTOM WIDTH=15 HEIGHT=1 BORDER=0></P> </TD> </TR> <TR> <TD BGCOLOR="#eeddcc"> <P><IMG SRC="interface_images/borderbottomleft.gif" NAME="graphics8" ALIGN=BOTTOM WIDTH=15 HEIGHT=15 BORDER=0></P> </TD> <TD BGCOLOR="#eeddcc"> <P><IMG SRC="interface_images/borderbottom.gif" NAME="graphics9" ALIGN=BOTTOM WIDTH=1 HEIGHT=15 BORDER=0></P> </TD> <TD BGCOLOR="#eeddcc"> <P><IMG SRC="interface_images/borderbottomright.gif" NAME="graphics10" ALIGN=BOTTOM WIDTH=15 HEIGHT=15 BORDER=0></P> </TD> </TR> </TABLE> </CENTER> <P><BR><BR> </P> </BODY> </HTML>
<table> <tr> <td>top left</td> <td>top right</td> </tr> <tr> <td>bottom left</td> <td>bottom right</td> </tr> </table>
<table> <tr> <td>top left</td> <td>top right</td> </tr> <tr> <td>bottom left</td> <td>bottom right</td> </tr> </table>
I'm interested in coding a program (in C\C++ or Python) for some low-level audio control in Windows. What I mean is, I want to deal with the actual samples from the stereo output. I don't want to import sound files or anything like that, I just want to output audio based on direct manipulation of samples, which is what this program should do. Example, I want to be able to play a 440 Hz sine wave sound by just writing samples following the sine function over time (using the sample rate and the frequency to get the said 440 Hz)
Any suggestions on where to start? I'm not very experienced in either C\C++ or Python, but I just need a few complex and interesting projects to push my skills further. Thanks! - L.
/dev/dsp
sound interface (which, incidentally, works fine in
cygwin). Apart from the audio-device stuff there's just some very basic stuff that builds a waveform from the sine function before playing it. The code is a little more complicated than you absolutely basically need, as it has a simple
envelope which fades the volume in and out for each note (without this you hear a nasty click at the beginning and end).
/*
playwave.c
Copyright (c) 2005 W. Finlay McWalter
Licence: your choice of GPL, GFDL, or CCbySA
Plays a given tone for a brief period of time, using the system's /dev/dsp
interface. Tested using cygwin (should work on linux too).
Version history:
v1. Basic version
v2. Adds simple envelope (attack and release) to avoid nasty clicks
between notes
v3. Change to 16 bit signed (LE) output (wow, so much better), and
make envelope code more programmable.
Notes:
- Current build produces signed 16 bit 44100 Hz mono little endian raw PCM
- Samples are appended to a file called "./outfile". This allows importing
the data into audacity and listening to it without the gaps imposed
by multiple invocations of the program.
Help on tone arithmetic: http://en.wikipedia.org/wiki/Physics_of_music
Programming notes:
http://www.oreilly.de/catalog/multilinux/excerpt/ch14-05.htm
http://davmac.org/davpage/linux/linux-sound.html
http://www.4front-tech.com/pguide/audio.html
Sample invocation (close encounters):
rm outfile ; touch outfile ; ./playwave 440 10000 ; ./playwave 495 10000 ;
./playwave 392 10000 ; ./playwave 196 10000 ; ./playwave 294 10000
*/
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/soundcard.h>
#include <math.h>
#define CHANNELS 1
#define RATE 44100 /* samples/sec */
#define LENGTH 0.8f /* seconds */
#define SIZE 2 /* bytes per sample */
#define NUM_SAMPLES_PER_BUFFER ((int)(LENGTH*RATE*SIZE*CHANNELS)/2)
// ENVELOPE FRACTION defines the proportion of the sample buffer that
// is shaped by the envelope function. So to shape the beginning and
// ending 10th, set envelope fraction to 10. ENVELOPE_FRACTION must
// be an integer.
#define ENVELOPE_FRACTION 3
int main (int argc, char** argv){
int audioDevice;
int outfile;
int status;
unsigned int arg;
int counter;
int x;
float angle;
int num_samples_in_waveform;
float volume = 6.0f;
signed short buf[NUM_SAMPLES_PER_BUFFER];
int freq = 440;
float value;
float vol_multiplier;
if (argc != 3){
fprintf(stderr, "usage: playwave <frequency> <volume>");
exit(1);
}
freq = atof(argv[1]);
volume = atof(argv[2]);
/* compute waveform */
num_samples_in_waveform = RATE/freq;
for (x=0; x< NUM_SAMPLES_PER_BUFFER; x++){
angle = (2.0f * 3.14159f * (float)x) / (float)num_samples_in_waveform;
value = sin(angle);
vol_multiplier = 1.0f;
// envelope: lead in
if(x < (NUM_SAMPLES_PER_BUFFER/ENVELOPE_FRACTION)){
vol_multiplier = (ENVELOPE_FRACTION * (float)x) / ((float)NUM_SAMPLES_PER_BUFFER) ;
}
// envelope: lead out
if(x > ((ENVELOPE_FRACTION-1)*NUM_SAMPLES_PER_BUFFER)/ENVELOPE_FRACTION){
vol_multiplier = (ENVELOPE_FRACTION * (NUM_SAMPLES_PER_BUFFER-x)) / ((float)NUM_SAMPLES_PER_BUFFER) ;
}
buf[x] = (signed short)(volume * value * vol_multiplier);
}
outfile = open("outfile", O_RDWR|O_APPEND|O_CREAT);
if (outfile < 0) {
perror("open of opening outfile failed");
exit(1);
}
status = write(outfile, buf, sizeof(buf));
if (status != sizeof(buf))
perror("wrote wrong number of bytes");
close(outfile);
// Now write that out to the audio device
/* open sound device */
audioDevice = open("/dev/dsp", O_RDWR);
if (audioDevice < 0) {
perror("open of /dev/dsp failed");
exit(1);
}
/* set format */
arg = AFMT_S16_LE;
status = ioctl(audioDevice, SNDCTL_DSP_SETFMT, &arg);
if (status == -1) {
perror("SNDCTL_DSP_SETFMT");
exit(1);
}
arg = CHANNELS; /* mono or stereo */
status = ioctl(audioDevice, SOUND_PCM_WRITE_CHANNELS, &arg);
if (status == -1)
perror("SOUND_PCM_WRITE_CHANNELS ioctl failed");
if (arg != CHANNELS)
perror("unable to set number of channels");
arg = RATE; /* sampling rate */
status = ioctl(audioDevice, SOUND_PCM_WRITE_RATE, &arg);
if (status == -1)
perror("SOUND_PCM_WRITE_WRITE ioctl failed");
status = write(audioDevice, buf, sizeof(buf));
if (status != sizeof(buf))
perror("wrote wrong number of bytes");
/* wait for playback to complete before recording again */
status = ioctl(audioDevice, SOUND_PCM_SYNC, 0);
if (status == -1)
perror("SOUND_PCM_SYNC ioctl failed");
close(audioDevice);
}
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void SineGen(float step, int length, FILE *fp);
void NoiseGen(int length, FILE *fp);
void SquareGen(float step, int length, FILE *fp);
#define PI 3.14159265
#define S_RATE 44100 // Sample rate
#define B_RATE 32768 // Bit rate (16 bits = 2^16 / 2 = 32768)
int main()
{
short unsigned int choice;
unsigned int length;
float freq, step;
do
{
printf("\nEnter frequency: ");
scanf("%f", &freq);
if (freq < 1)
{
printf("Incorrect frequency.");
continue;
}
printf("\nEnter length: ");
scanf("%i", &length);
if (length < 1)
{
printf("Incorrect length.");
continue;
}
printf("\n1. Sine wave\n2. White noise\n3. Square wave\n\nChoice? ");
scanf("%i", &choice);
if (choice < 1 || choice > 3)
{
printf("Bad choice.");
continue;
}
}
while(freq < 1 && length < 1 && choice < 1 || choice > 3);
step = (freq / S_RATE); // Converts frequency (Hz) into step size.
FILE *fp;
fp = fopen("wave.raw", "w"); // Open the file, and write.
switch (choice)
{
case 1: SineGen(step, length, fp); break;
case 2: NoiseGen(length, fp); break;
case 3: SquareGen(step, length, fp);
default: break;
}
fclose(fp); // File written, close.
getch();
return 0;
}
void SineGen(float step, int length, FILE *fp)
{
int j;
float sample, i;
step *= 360;
for (j = 0; j < length; ++j)
for (i = 0; i < 360; i += step) // The pitch is raised by increasing the step size.
{
sample = (sin(i * PI / 180)) * B_RATE; // Convert degrees to radians for sin(), scale float to correct amplitude.
fprintf(fp, "%i\t", (int) sample); // Cast to int for correct parsing by wave editor.
printf("%i\t", (int) sample); // Display as integers.
}
}
void NoiseGen(int length, FILE *fp)
{
srand((unsigned)time(NULL)); // Uses system clock as inital seed.
int j, randsamp;
for (j = 0; j < length; ++j)
{
randsamp = ((B_RATE * 2) * rand() / RAND_MAX) - B_RATE; // Generates random number between -B_RATE to B_RATE.
fprintf(fp, "%i\t", randsamp);
printf("%i\t", randsamp);
}
}
void SquareGen(float step, int length, FILE *fp)
{
int j;
float i;
step = 1 / step;
for (j = 0; j < length; ++j)
{
for (i = 0; i < step; ++i)
{
fprintf(fp, "%i\t", -B_RATE);
printf("%i\t", -B_RATE);
}
for (i = 0; i < step; ++i)
{
fprintf(fp, "%i\t", B_RATE);
printf("%i\t", B_RATE);
}
}
}