er

Berbagai Tutorial dan Info Menarik

Belajar, Berjuang, dan Bertaqwa

Saturday 13 December 2014

Gambar Kos 3D dengan Opengl



Source Code :

#include <stdlib.h> // standard definitions
#include <math.h> // math definitions
#include <stdio.h> // standard I/O
#include <iostream>

// include files are in a slightly different location for MacOS
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

..............................
Download source code lengkap Di Sini


Hasil :





Keterangan :
Untuk masalah gambar, gunakan gambar dengan format BMP. Letakkan gambar di folder yang sama dengan letak penyimpanan file codeblock tersebut.

Perhatikan juga hal ini :

Untuk melihat dari berbagai sudut kamar, ganti gluLookAt, berikut script-nya :
gluLookAt(1.0, 0.8,  3.3,    1.0, 0.8,  1.0,    0, 1, 0);

gluLookAt(0.7, 5.2,  1.2,    0.7, 0.0,  1.2,    0, 0, 1);

gluLookAt(0.0, 0.95,  3.0,    1.5, 0.95,  1.0,    0, 1, 0);

gluLookAt(0.0, 0.95,  2.8,    1.0, 0.95,  1.0,    0, 1, 0);

Pilih salah satu saja.
Sekian. 
Regards.

Friday 5 December 2014

Mantan Kepala Dinas Pariwisata Kabupaten Tegal Ditahan


Menurut Kepala Kejaksaan Negeri Slawi , Hj, Unaisi Hetty Nining,SH,MH mengatakan, mantan kepala Dinas Pariwisata dan kebudayaan Kabupaten Tegal, Dra. Indah Winarni ditahan dan dititipkan di Lapas kota Tegal. Sebelumnya, tersangka sudah menjalani serangkian pemeriksaan sehingga berkas tersangka dinyatakan P 21. “ Penahanan dilakukan setelah Satreskrim Polres Tegal melimpahkan berkas hasil penyidikan kasus dugaan korupsi proyek Road Race Cacaban yang sudah dinyatakan lengkap (P21). Tersangka dalam kapasitasnya sebagai pengguna anggaran,”
Baca Selengkapnya

Lumix Camera

Lumix Camera: Panasonic Lumix DMC-GF6. Comes with a 180-degree-tiltable LCD and enables unlimited artistic expression with a variety of creative filters, with new feature new self shot, perfect camera for you who like selfie. The Lumix DMC-GF6 compact mirror less digital camera delivers amazing image.



Find this cool stuff here: http://zocko.it/LHDh1

Coolpix S3500 Camera

Coolpix S3500 Camera: Nikon Coolpix S3500 Camera in orange.



Find this cool stuff here: http://zocko.it/LHDiF

Transparent Baby G Watch

Transparent Baby G Watch: Baby G BG 6900 7BDR by CASIO. Tough digital watches built Shock Proof, semi-transparent resin case and band with modern marine styles and it also stylish and cute, water resistant 200 m, EL backlight with afterglow.



Find this cool stuff here: http://zocko.it/LHDhq

Playstation 4 White

Playstation 4 White: Sony Ps 4 White 500gb. The PS4 is ready to rock your gaming world, immortalize your most epic moments and share at the press of a button, share it to witch, UStream, Facebook and Twitter. Are you ready for the new gaming experience ?



Find this cool stuff here: http://zocko.it/LHDfn

Oppo Joy Phone

Oppo Joy Phone: Oppo Joy R1001Phone 4gb. With the system of colorOS oppo joy has the new and smart function of gesture panel. And dont worry when you wearing a glove because this phone has a gloves mode, you can access your phone and touch it even when you wearing a gloves. Dual sim card.



Find this cool stuff here: http://zocko.it/LHDgN

Acer Iconia W511

Acer Iconia W511: Acer Iconia W511. More just than a tablet this smart device give you access to your data on any of your devices, over a new twist, gives benefits of a tablet with a touch, type, and view experience. This Acer Iconia is lightweight, the battery can keep up until 18 hours.



Find this cool stuff here: http://zocko.it/LHDfs

Black Strap Watch

Black Strap Watch: Men Leather Strap Watch by 24:01. Black watch with unique design, strap made of silicon and metal case, with a date and day feature, watch that can go formal or casual way, this watch will be your next favorite watch.





Find this cool stuff here: http://zocko.it/LHDe8

Wednesday 3 December 2014

3D Sederhana Dengan OpenGL

Gambar 3D sederhana

Source Code :


#include <stdlib.h> // standard definitions
#include <math.h> // math definitions
#include <stdio.h> // standard I/O
#include <iostream>

// include files are in a slightly different location for MacOS
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

using namespace std;

GLuint texture[4];
GLint slices=16;
GLint stacks=16;
struct Image {
    unsigned long sizeX;
    unsigned long sizeY;
    char *data;
};
typedef struct Image Image;

static unsigned int getint(FILE *fp)
{
    int c, c1, c2, c3;

    // get 4 bytes
    c = getc(fp);
    c1 = getc(fp);
    c2 = getc(fp);
    c3 = getc(fp);

    return ((unsigned int) c) +
    (((unsigned int) c1) << 8) +
    (((unsigned int) c2) << 16) +
    (((unsigned int) c3) << 24);
}

static unsigned int getshort(FILE *fp)
{
    int c, c1;

    //get 2 bytes
    c = getc(fp);
    c1 = getc(fp);

    return ((unsigned int) c) + (((unsigned int) c1) << 8);
}

int ImageLoad(const char *filename, Image *image) {
    FILE *file;
    unsigned long size;                 // size of the image in bytes.
    unsigned long i;                    // standard counter.
    unsigned short int planes;          // number of planes in image (must be 1)
    unsigned short int bpp;             // number of bits per pixel (must be 24)
    char temp;                          // used to convert bgr to rgb color.

    // make sure the file is there.
    if ((file = fopen(filename, "rb"))==NULL) {
        printf("File Not Found : %s\n",filename);
        return 0;
    }

    // seek through the bmp header, up to the width/height:
    fseek(file, 18, SEEK_CUR);

    // No 100% errorchecking anymore!!!

    // read the width
    image->sizeX = getint (file);
    //printf("Width of %s: %lu\n", filename, image->sizeX);

    // read the height
    image->sizeY = getint (file);
    //printf("Height of %s: %lu\n", filename, image->sizeY);

    // calculate the size (assuming 24 bits or 3 bytes per pixel).
    size = image->sizeX * image->sizeY * 3;

    // read the planes
    planes = getshort(file);
    if (planes != 1) {
        printf("Planes from %s is not 1: %u\n", filename, planes);
        return 0;
    }

    // read the bpp
    bpp = getshort(file);
    if (bpp != 24) {
        printf("Bpp from %s is not 24: %u\n", filename, bpp);
        return 0;
    }

    // seek past the rest of the bitmap header.
    fseek(file, 24, SEEK_CUR);

    // read the data.
    image->data = (char *) malloc(size);
    if (image->data == NULL) {
        printf("Error allocating memory for color-corrected image data");
        return 0;
    }

    if ((i = fread(image->data, size, 1, file)) != 1) {
        printf("Error reading image data from %s.\n", filename);
        return 0;
    }

    for (i=0;i<size;i+=3) { // reverse all of the colors. (bgr -> rgb)
        temp = image->data[i];
        image->data[i] = image->data[i+2];
        image->data[i+2] = temp;
    }

    // we're done.
    return 1;
}
Image * loadTexture(const char *filename)
{
    Image *image1;
    // allocate space for texture
    image1 = (Image *) malloc(sizeof(Image));
    if (image1 == NULL) {
        printf("Error allocating space for image");
        exit(0);
    }
    if (!ImageLoad(filename, image1)) {
        exit(1);
    }
    return image1;
}

void setTexture(void)
{
    glClearColor(1., 0.0, 0.5, 0.0);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);

    Image *image1[4];

    image1[0] = loadTexture("worldmap.bmp");
    image1[1] = loadTexture("rivet_steel_1.bmp");
    image1[2] = loadTexture("test.bmp");
    image1[3] = loadTexture("black.bmp");

    glGenTextures(4, texture);
    for (int i=0; i<4; i++)
    {
        if(image1[0] == NULL)
        {
            printf("Image was not returned from loadTexture\n");
            exit(0);
        }
        glBindTexture(GL_TEXTURE_2D, texture[i]);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
        glTexImage2D(GL_TEXTURE_2D, 0, 3, image1[i]->sizeX, image1[i]->sizeY, 0,
                     GL_RGB, GL_UNSIGNED_BYTE, image1[i]->data);
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    }
    glEnable(GL_TEXTURE_2D);
    glShadeModel(GL_FLAT);
}

void setMaterial()
{
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_NORMALIZE);
    glEnable(GL_COLOR_MATERIAL);

    glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ) ;
}

void setLighting()
{
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    // Create light components
    GLfloat ambientLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
    GLfloat diffuseLight[] = { 1.0f, 1.0f, 1.0f, 1.0f };
    GLfloat specularLight[] = { 1.0f, 1.0f, 1.0f, 1.0f };
    GLfloat position[] = { -2.5f, 2.0f, 3.0f, 1.0f };

    // Assign created components to GL_LIGHT0
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
    glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
    glLightfv(GL_LIGHT0, GL_POSITION, position);
}

void setCamera(){
    // setting proyeksi kamera
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0, 3.0/3.0, 1, 40);

    // setting posisi kamera
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(2, 2, 2, 0, 0, 0, 0, 1, 0);
}

void drawBox(float x1,float y1,float z1, float x2, float y2, float z2)
{
    glPushMatrix();
    glBegin(GL_QUADS);
    //depan
    glTexCoord2f(0.0, 0.0);glVertex3f(x1,y1,z1);
    glTexCoord2f(1.0, 0.0);glVertex3f(x2,y1,z1);
    glTexCoord2f(1.0, 1.0);glVertex3f(x2,y2,z1);
    glTexCoord2f(0.0, 1.0);glVertex3f(x1,y2,z1);
    //atas
    glTexCoord2f(0.0, 0.0);glVertex3f(x1,y2,z1);
    glTexCoord2f(0.0, 1.0);glVertex3f(x2,y2,z1);
    glTexCoord2f(1.0, 1.0);glVertex3f(x2,y2,z2);
    glTexCoord2f(1.0, 0.0);glVertex3f(x1,y2,z2);
    //belakang
    glTexCoord2f(0.0, 0.0);glVertex3f(x1,y2,z2);
    glTexCoord2f(0.0, 1.0);glVertex3f(x2,y2,z2);
    glTexCoord2f(1.0, 1.0);glVertex3f(x2,y1,z2);
    glTexCoord2f(1.0, 0.0);glVertex3f(x1,y1,z2);
    //bawah
    glTexCoord2f(0.0, 0.0);glVertex3f(x1,y1,z2);
    glTexCoord2f(1.0, 0.0);glVertex3f(x2,y1,z2);
    glTexCoord2f(1.0, 1.0);glVertex3f(x2,y1,z1);
    glTexCoord2f(0.0, 1.0);glVertex3f(x1,y1,z1);
    //samping kiri
    glTexCoord2f(0.0, 0.0);glVertex3f(x1,y1,z1);
    glTexCoord2f(1.0, 0.0);glVertex3f(x1,y2,z1);
    glTexCoord2f(1.0, 1.0);glVertex3f(x1,y2,z2);
    glTexCoord2f(0.0, 1.0);glVertex3f(x1,y1,z2);
    //samping kanan
    glTexCoord2f(0.0, 0.0);glVertex3f(x2,y1,z1);
    glTexCoord2f(1.0, 0.0);glVertex3f(x2,y2,z1);
    glTexCoord2f(1.0, 1.0);glVertex3f(x2,y2,z2);
    glTexCoord2f(0.0, 1.0);glVertex3f(x2,y1,z2);
    glEnd();
    glPopMatrix();
}

void kunci(unsigned char key, int x, int y) {
    switch (key)
    {
        case 27 :
        case 'q':
            exit(0);
        break;
    }
    glutPostRedisplay();
}

void drawPC()
{
    glBindTexture(GL_TEXTURE_2D, texture[2]);
    drawBox(-0.5,0.0,0.5,0.5,0.7,0.45);

    glBindTexture(GL_TEXTURE_2D, texture[3]);
    drawBox(-0.55,-0.05,0.48,0.55,0.75,0.40);
    drawBox(-0.1,-0.1,0.48,0.1,-0.05,0.40);
    drawBox(-0.2,-0.15,0.6,0.2,-0.1,0.30);

       glBindTexture(GL_TEXTURE_2D, texture[2]);
    drawBox(-0.5,0.0,0.5,0.5,0.7,0.45);

    glBindTexture(GL_TEXTURE_2D, texture[3]);
    drawBox(0.55,-0.05,0.48,0.55,0.75,0.40);
    drawBox(0.1,-0.1,0.48,0.1,-0.05,0.40);
    drawBox(0.2,-0.15,0.6,0.2,-0.1,0.30);
}

void renderScene(void){
    glClearColor(1,1,1,0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glShadeModel(GL_SMOOTH);

    glPushMatrix();
    //glTranslatef(1.0,0.50,0.12);
    glScalef(0.5,0.5,0.5);
    drawPC();
    glPopMatrix();

    /*
    //CONTOH MENGGAMBAR SPHERE
    glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);
    glBindTexture(GL_TEXTURE_2D, texture[0]);
    glutSolidSphere(0.5,50,50);
    glDisable(GL_TEXTURE_GEN_S);
    glDisable(GL_TEXTURE_GEN_T);
    */

    // Draw a red x-axis, a green y-axis, and a blue z-axis.
    glBegin(GL_LINES);
    glColor3f(1, 0, 0); glVertex3f(0, 0, 0); glVertex3f(10, 0, 0);
    glColor3f(0, 1, 0); glVertex3f(0, 0, 0); glVertex3f(0, 10, 0);
    glColor3f(0, 0, 1); glVertex3f(0, 0, 0); glVertex3f(0, 0, 10);
    glEnd();

    glutSwapBuffers();
}

void init(){
    //setMaterial();
    setTexture();
    setLighting();
    setCamera();
}


int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitWindowSize(600,600);
    glutInitWindowPosition(100,100);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
    glutCreateWindow("Primitive Object");
    glutDisplayFunc(renderScene);
    glutKeyboardFunc(kunci);
    init();
    glutMainLoop();
    return 0;

}


Screenshot :


Monday 24 November 2014

Bentuk Sederhana 3D dengan Opengl


Source Code :
#include <Windows.h>
#include <iostream>
#include <gl\GL.h>
#include <gl\GLU.h>
#include <gl\glut.h>
#include <math.h>

void cube()
{
//menggambar kubus dan transformasi tarnslasi ke titik 0.5 0.5 0.5 dan skala 1 1 1
glPushMatrix();
glTranslated(0.7,0.7,0.7);//cube
glScaled(0.5,0.5,0.5);
glutSolidCube(1.0);
glPopMatrix();

glPushMatrix();
glTranslated(0.7,0.7,0.7);//cube
glScaled(0.7,0.2,0.7);
glutSolidCube(1.0);
glPopMatrix();

glPushMatrix();
glTranslated(0.7,0.9,0.7);//cube
glScaled(0.5,1.0,0.5);
glutSolidCube(1.0);
glPopMatrix();



// mobil
    glPushMatrix();
    glPushMatrix();                   // body
    glScalef(2,.5,1);
    glutSolidCube(.5);
    glPopMatrix();
    glTranslatef(0,0,.25);
    glPushMatrix();
    glTranslatef(-.4,-.2,0);
    glutSolidTorus(.05,.1,8,8);       // wheel
    glTranslatef(.8,0,0);
    glutSolidTorus(.05,.1,8,8);       // wheel
    glPopMatrix();
    glTranslatef(0,0,-.5);
    glPushMatrix();
    glTranslatef(-.4,-.2,0);
    glutSolidTorus(.05,.1,8,8);       // wheel
    glTranslatef(.8,0,0);
    glutSolidTorus(.05,.1,8,8);       // wheel
    glPopMatrix();
    glPopMatrix();

    glPopMatrix();

}


void setMaterial()
{
//set properties of surfaces material
GLfloat mat_ambient[] = {0.7f,0.7f,0.7f,1.0f}; // ada 4 jenis material yang dipakai, dengan kombinasi warna tertentu
GLfloat mat_diffuse[] = {0.6f,0.6f,0.6f,1.0f};
GLfloat mat_specular[] = {1.0f,1.0f,1.0f,1.0f};
GLfloat mat_shininess[] = {50.0f};
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
}


void setLighting()
{
//set light sources
GLfloat lightIntensity[] = {0.7f,0.7f,0.7f,1.0f};//mensetting pencahayaan
GLfloat light_position[] = {2.0f,6.0f,3.0f,0.0f};
glLightfv(GL_LIGHT0,GL_DIFFUSE,lightIntensity);
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
}


void setViewport()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
double winHt = 1.0;//half height of the window
glOrtho(-winHt*64/48,winHt*64/48,-winHt,winHt,0.1,100.0);
}


void setCamera()
{
//set the camera
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(9.3,2.3,5.0,0,0.25,0,0.0,3.0,0.0);
}


void displayObject()
{
setMaterial();
setLighting();
setViewport();
setCamera();
//startDrawing
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
cube();//memanggil fungsi menggambar kubus
glFlush();//mengirim smua objek untuk dirender
}


int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(640,480);
glutInitWindowPosition(100,100);
glutCreateWindow("3d grafkom");
glutDisplayFunc(displayObject);//fungsi dari display object yang menggabungkan kubus lighting material dan kamera
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glClearColor(1.0f,1.0f,1.0f,0.0f);
glViewport(0,0,640,480);
glutMainLoop();

}


Screenshot :

Gambar Kubus Sederhana 3D dengan Opengl


Source Code :
#include <Windows.h>
#include <iostream>
#include <gl\GL.h>
#include <gl\GLU.h>
#include <gl\glut.h>
#include <math.h>

void cube()
{
//menggambar kubus dan transformasi tarnslasi ke titik 0.5 0.5 0.5 dan skala 1 1 1
glPushMatrix();
glTranslated(0.3,0.3,0.3);//cube
glScaled(0.4,0.4,0.4);
glutSolidCube(1.0);
glPopMatrix();
}
void setMaterial()
{
//set properties of surfaces material
GLfloat mat_ambient[] = {0.7f,0.7f,0.7f,1.0f}; // ada 4 jenis material yang dipakai, dengan kombinasi warna tertentu
GLfloat mat_diffuse[] = {0.6f,0.6f,0.6f,1.0f};
GLfloat mat_specular[] = {1.0f,1.0f,1.0f,1.0f};
GLfloat mat_shininess[] = {50.0f};
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
}
void setLighting()
{
//set light sources
GLfloat lightIntensity[] = {0.7f,0.7f,0.7f,1.0f};//mensetting pencahayaan
GLfloat light_position[] = {2.0f,6.0f,3.0f,0.0f};
glLightfv(GL_LIGHT0,GL_DIFFUSE,lightIntensity);
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
}
void setViewport()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
double winHt = 1.0;//half height of the window
glOrtho(-winHt*64/48,winHt*64/48,-winHt,winHt,0.1,100.0);
}
void setCamera()
{
//set the camera
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(9.3,2.3,5.0,0,0.25,0,0.0,3.0,0.0);
}

void displayObject()
{
setMaterial();
setLighting();
setViewport();
setCamera();
//startDrawing
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
cube();//memanggil fungsi menggambar kubus
glFlush();//mengirim smua objek untuk dirender
}


int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(640,480);
glutInitWindowPosition(100,100);
glutCreateWindow("3d grafkom");
glutDisplayFunc(displayObject);//fungsi dari display object yang menggabungkan kubus lighting material dan kamera
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glClearColor(1.0f,1.0f,1.0f,0.0f);
glViewport(0,0,640,480);
glutMainLoop();

}


Screenshot :

Tuesday 11 November 2014

Gambar Laba-Laba Sederhana dengan OpenGL


source code :

#include <iostream>
#include <GL/glut.h>
#include <math.h>

//LINGKARAN


const double PI = 3.141592653589793;

void drawCircle(float x_tengah,float y_tengah,float radius){
    glBegin(GL_POLYGON);

    int jumlah_titik = 50;

    for (int i=0;i<=360;i++)
    {
        float sudut = i*(2*PI/jumlah_titik);
        float x = x_tengah + radius*cos(sudut);
        float y = y_tengah + radius*sin(sudut);
        glVertex2f(x,y);
    }

    glEnd();

    //sikil kanan tengah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.70, 0.00, 0.0);
glVertex3f (0.25, 0.00, 0.0);

glVertex3f (0.25, 0.00, 0.0);
glVertex3f (0.25, 0.02, 0.0);

glVertex3f (0.25, 0.02, 0.0);
glVertex3f (0.70, 0.02, 0.0);

glVertex3f (0.70, 0.02, 0.0);
glVertex3f (0.70, 0.00, 0.0);

glEnd ();

//sikil kanan atas
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.60, 0.40, 0.0);
glVertex3f (0.05, 0.20, 0.0);

glVertex3f (0.05, 0.20, 0.0);
glVertex3f (0.05, 0.18, 0.0);

glVertex3f (0.05, 0.18, 0.0);
glVertex3f (0.60, 0.38, 0.0);

glVertex3f (0.60, 0.18, 0.0);
glVertex3f (0.60, 0.40, 0.0);

glEnd ();

//sikil kanan bawah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.60, -0.45, 0.0);
glVertex3f (0.05, -0.20, 0.0);

glVertex3f (0.05, -0.20, 0.0);
glVertex3f (0.05, -0.18, 0.0);

glVertex3f (0.05, -0.18, 0.0);
glVertex3f (0.60, -0.43, 0.0);

glVertex3f (0.60, -0.18, 0.0);
glVertex3f (0.60, -0.45, 0.0);

glEnd ();


//sikil kiri tengah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (-0.70, 0.00, 0.0);
glVertex3f (-0.25, 0.00, 0.0);

glVertex3f (-0.25, 0.00, 0.0);
glVertex3f (-0.25, 0.02, 0.0);

glVertex3f (-0.25, 0.02, 0.0);
glVertex3f (-0.70, 0.02, 0.0);

glVertex3f (-0.70, 0.02, 0.0);
glVertex3f (-0.70, 0.00, 0.0);

glEnd ();

//sikil kiri atas
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (-0.60, 0.40, 0.0);
glVertex3f (-0.05, 0.20, 0.0);

glVertex3f (-0.05, 0.20, 0.0);
glVertex3f (-0.05, 0.18, 0.0);

glVertex3f (-0.05, 0.18, 0.0);
glVertex3f (-0.60, 0.38, 0.0);

glVertex3f (-0.60, 0.18, 0.0);
glVertex3f (-0.60, 0.40, 0.0);

glEnd ();

//sikil kiri bawah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (-0.60, -0.45, 0.0);
glVertex3f (-0.05, -0.20, 0.0);

glVertex3f (-0.05, -0.20, 0.0);
glVertex3f (-0.05, -0.18, 0.0);

glVertex3f (-0.05, -0.18, 0.0);
glVertex3f (-0.60, -0.43, 0.0);

glVertex3f (-0.60, -0.18, 0.0);
glVertex3f (-0.60, -0.45, 0.0);

glEnd ();

//jari kanan bawah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.60, -0.42, 0.0);
glVertex3f (0.58, -0.42, 0.0);

glVertex3f (0.58, -0.42, 0.0);
glVertex3f (0.58, -0.49, 0.0);

glVertex3f (0.58, -0.49, 0.0);
glVertex3f (0.60, -0.49, 0.0);

glVertex3f (0.60, -0.49, 0.0);
glVertex3f (0.60, -0.42, 0.0);

glEnd ();

//jari kiri bawah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (-0.60, -0.42, 0.0);
glVertex3f (-0.58, -0.42, 0.0);

glVertex3f (-0.58, -0.42, 0.0);
glVertex3f (-0.58, -0.49, 0.0);

glVertex3f (-0.58, -0.49, 0.0);
glVertex3f (-0.60, -0.49, 0.0);

glVertex3f (-0.60, -0.49, 0.0);
glVertex3f (-0.60, -0.42, 0.0);

glEnd ();

//jari kiri atas
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (-0.60, 0.30, 0.0);
glVertex3f (-0.58, 0.30, 0.0);

glVertex3f (-0.58, 0.30, 0.0);
glVertex3f (-0.58, 0.39, 0.0);

glVertex3f (-0.58, 0.39, 0.0);
glVertex3f (-0.60, 0.39, 0.0);

glVertex3f (-0.60, 0.39, 0.0);
glVertex3f (-0.60, 0.30, 0.0);

glEnd ();
//jari kanan atas
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.60, 0.30, 0.0);
glVertex3f (0.58, 0.30, 0.0);

glVertex3f (0.58, 0.30, 0.0);
glVertex3f (0.58, 0.39, 0.0);

glVertex3f (0.58, 0.39, 0.0);
glVertex3f (0.60, 0.39, 0.0);

glVertex3f (0.60, 0.39, 0.0);
glVertex3f (0.60, 0.30, 0.0);

glEnd ();

//jari kanan tengah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (0.70, 0.00, 0.0);
glVertex3f (0.68, 0.00, 0.0);

glVertex3f (0.68, 0.00, 0.0);
glVertex3f (0.68, -0.07, 0.0);

glVertex3f (0.68, -0.07, 0.0);
glVertex3f (0.70, -0.07, 0.0);

glVertex3f (0.70, -0.07, 0.0);
glVertex3f (0.70, 0.00, 0.0);

glEnd ();

//jari kiri tengah
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (1.0, 1.0, 1.0);

glVertex3f (-0.70, -0.00, 0.0);
glVertex3f (-0.68, -0.00, 0.0);

glVertex3f (-0.68, -0.00, 0.0);
glVertex3f (-0.68, -0.07, 0.0);

glVertex3f (-0.68, -0.07, 0.0);
glVertex3f (-0.70, -0.07, 0.0);

glVertex3f (-0.70, -0.07, 0.0);
glVertex3f (-0.70, -0.00, 0.0);

glEnd ();

//mata kanan
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (0.4, 0.4, 0.4);

glVertex3f (0.10, 0.43, 0.0);
glVertex3f (0.05, 0.43, 0.0);

glVertex3f (0.05, 0.43, 0.0);
glVertex3f (0.05, 0.45, 0.0);

glVertex3f (0.05, 0.45, 0.0);
glVertex3f (0.10, 0.45, 0.0);

glVertex3f (0.10, 0.45, 0.0);
glVertex3f (0.10, 0.43, 0.0);

glEnd ();

//mata kiri
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (0.4, 0.4, 0.4);

glVertex3f (-0.10, 0.43, 0.0);
glVertex3f (-0.05, 0.43, 0.0);

glVertex3f (-0.05, 0.43, 0.0);
glVertex3f (-0.05, 0.45, 0.0);

glVertex3f (-0.05, 0.45, 0.0);
glVertex3f (-0.10, 0.45, 0.0);

glVertex3f (-0.10, 0.45, 0.0);
glVertex3f (-0.10, 0.43, 0.0);

glEnd ();

//mulut
glPushMatrix ();
glLineWidth (1.9f);
glBegin (GL_LINES);
glBegin (GL_POLYGON);
glColor3f (0.4, 0.4, 0.4);

glVertex3f (-0.02, 0.35, 0.0);
glVertex3f (0.02, 0.35, 0.0);

glVertex3f (0.02, 0.35, 0.0);
glVertex3f (0.02, 0.37, 0.0);

glVertex3f (0.02, 0.37, 0.0);
glVertex3f (-0.02, 0.37, 0.0);

glVertex3f (-0.02, 0.37, 0.0);
glVertex3f (-0.02, 0.35, 0.0);

glEnd ();
    glFlush();
}



void display() {
drawCircle(0,0,0.3);
glColor3f (255/255, 255/255, 255/255);
drawCircle(0,0.40,0.15);
}


int main(int argc, char **argv){
    glutInit(&argc,argv);
    glutInitWindowSize(800,800);
    glutInitWindowPosition(100,100);//jarak windows dari tepi monitor

    glutCreateWindow("laba-laba");
    glutDisplayFunc(display);
    glutMainLoop();//mulai render
    return 0;
}



Wednesday 29 October 2014

Membandingkan kualitas audio berdasarkan Sample Rate, Bit Depth, dan Bit Rate



A.    Tujuan
  1. Mahasiswa dapat mengganti nilai Sample dan Bit Depth sebuah file audio.
  2. Mahasiswa dapat menjelaskan perbandingan kualitas audio berdasarkan nilai Bit Depth, Sample Rate.
B.     Teori Singkat
          Audio adalah getaran udara pada frekwensi yang dapat didengar oleh telinga manusia sehingga disebut dengan frekwensi suara atau freuensi audio. Frekuensi audi berada diantara 20 Hz sd 20 KHz.
          Bit Depth adalah nilai resolusi suara atau jumlah tingkatan level suara. Audio 8 bit menyediakan 2 pangkat delapan atau 256 level. Audio 16 bit menyediakan 65.536 level dan audio 32 bit memiliki jumlah jangkauan 2 pangkat 32 . Makin tinggi nilai jangkauan makin baik kualitas. Namun demikian ukuran file yang diperlukan juga semakin besar. Sample Rate adalah beberapa gelombang yang di ambil dalam 1 detik. WAV (Windows Format Wave ) ini adalah format standar audio yang belum terkompres pada Windows, dan didukung di hampir semua sistem komputer. Hal ini juga dapat ringan dikompresi (sekitar 4:1) menggunakan codec ADPCM, tapi ini kurang banyak didukung pada platform non-jendela. Audacity dapat membaca dan menulis format ini, termasuk ADPCM pada semua platform.
          MP3 adalah audio format terkompresi itu adalah cara yang sangat populer untuk menyimpan musik. Hal ini dapat memampatkan audio dengan faktor 10:1 dengan sedikit penurunan dalam kualitas. Audacity dapat baik impor dan ekspor format ini. Ogg adalah format multimedia gratisan yang dirancang untuk streaming dan penyimpanan yang effiesien. Format ini dikembangkan oleh Xiph.org Foundation. Begitu pula Vorbis yang merupakan codec audio gratisan. Vorbis biasanya dipasang bersama Ogg, sehingga muncullah yang namanya Ogg Vorbis. Peluncuran format dan codec ini sebenarnya respon atas rencana pemilik MP3 pada tahun 1998 yang hendak mengenakan biaya lisensi untuk format MP3. OggVorbis sangat populer dikalangan open source, karena kualitas dan sifatnya yang gratis. Namun hingga saat ini walaupun gratis, masih sedikit player yang mendukung format ini, salah satu yang terkenal adalah winamp yang ikut mendukung format Ogg Vorbis.

          WMA ( Window Media Audio ) adalah codec untuk lossy compression, yang dikembangkan pertama sekali ujua untuk menyaingi MP3 oleh Microsoft. Sementara ini Microsoft memposisikan WMA bersaing dengan AAC yang digunakan pada produk Apple seperti iPod dan iTunes Music Strore. WMA juga menggunakan sistem Digital Rights Management seperti AAC untuk proteksi penggandaan dan membatasi pemutaran pada PC atau peranti tertentu. WMA audio stream hampir selalu dengan file ASF. Jika hanya membawa data audio, biasnya file mempunyai ekstensi .WMA. Adapula versi lossless untuk multichannel surround sound dan untuk voice encoding (WMA Voice).

C.    Alat dan Bahan
-          PC Intel® Celeron® CPU 877 @ 1.40GHz
-          Software Audition
-          File audio
·         Judul     : Risalah Hati (Dewa 19)
·         Ukuran  : 4.46 MB
·         Format  : MP3
·         Bit Rate            : 128 kbps

D.    Langkah Kerja
-          Buka Adobe Audition
-          Import File Audio dengan cara pada window File klik ikon Import File – Pilih file yang diinginkan – klik ganda file tersebut atau klik tombol Open.
-          Sekarang file yang akan diedit sudah berada pada window File.
-          Klik ganda ikon file yang akan di edit atau drag and drop ke window editor (Main)
-          Untuk melihat informasi tentang file ini letakkan pointer pada window editor, klik kanan dan pilih File Info.
-          Untuk mengganti Bit Depth  dan Sample Rate ,
o   Buka sesion baru: File – New
o   Pada Jendala New Waveform Pilih Sample Rate dan Bit Rate sesuai dengan yang dibutuhkan (tabel 1)
o   Klik OK, maka akan muncul file baru dengan nama untlited ,
-          Untuk memasukkan file lagu ke dalam untlited.
o   Klik kanan lagu yang akan di ganti sample rate dan bit depth nya,
o   Klik Copy
o   Kemudian buka file untlited dan paste kan lagu tadi di situ,
o   Maka adobe Audition akan mengenerate lagu menjadi ukuran sample rate dan bith depth yang kita inginkan
o   Maka sample rate dan bit depth lagu telah berubah.
-          Untuk menyimpan file lagu,
o   File untlited tadi bisa kita ganti namanya pada saat proses penyimpanan
o   Klik file untlited => file => save as => ganti nama sesuai dengan keinginan => klik OK
o   Maka file akan tersimpan dan namanya sudah berubah.


E.     Hasil Kerja
1.      Table Hasil
1.      Membandingkan berdasarkan Bit Dept

Simple Rate
Bit Dept
Ukuran File
Kualitas Suara
44100
8 bit
4.46 Mb
Tidak jernih karena terdapat suara bising
44100
16 bit
4.46 Mb
Suara bising(noise) masih ada tetapi sudah sangat kecil
44100
32 bit
4.46 Mb
Suara jernih

2.      Membandingkan berdasarkan Sample Rate
Simple Rate(Hz)
Bit Depth
Ukuran File
Kualitas Suara
11025
32 bit
1.11 MB
Suara tidak jernih, terdengar seperti audio tempo dulu
22050
32 bit
3.35 MB
Suara jernih (sedikit ada noise)
32000
32 bit
4.46 MB
Suara jernih
44100
32 bit
4.46 MB
Suara jernih
48000
32 bit
4.46 MB
Suara jernih dan suara lebih bergema
96000
32 bit
Tidak bisa disimpan



3.      Membandingkan berdasarkan  Bit Rate

Bit Rate
Sample Rate
Ukuran File
Kualitas Suara
20
11025
715 kb
Volume kecil, terdengar seperti audio tempo dulu, dan tidak jernih
32
11025
1.11 MB
Masih belum terdengar jernih
64
11025
5.27 kb
Tidak bisa di putar
128
11025
Tidak bisa disimpan
256
11025
Tidak bisa disimpan
320
11025
Tidak bisa disimpan


Bit Rate
Sample Rate
Ukuran File
Kualitas Suara
20
44100
Tidak bisa disimpan
32
44100
1.11 MB
Seperti suara yang berasal dari dalam air, tidak jelas.
64
44100
Tidak bisa disimpan
128
44100
2.23 MB
Jelas tapi masih sedikit noise yang terdengar
256
44100
8.93 MB
Suara jernih dan bergema
320
44100
11.1 MB
Suara jernih dan lebih bergema dari sebelumnya



F.     Kesimpulan

       Rate adalah menunjukkan jumlah sinyal audio yang diambil dalam satu detik ketika melakukan rekaman suara. Semakin tinggi nilai sample rate ini kualitas audio yang dimainkan semakin baik. Kualitas Audio ditentukan oleh Sample rate dan Bit Rate, Semakin tinggi  bit dep nya  maka kualitas suara akan semakin baik.