begin process at 2010 02 09 13:42:06
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Date et Heure

 > SIMULATION D'UN TIMECODE (CHRONOMETRE SPECIFIQUE À L'AUDIO-VISUEL)

SIMULATION D'UN TIMECODE (CHRONOMETRE SPECIFIQUE À L'AUDIO-VISUEL)


 Information sur la source

Note :
9 / 10 - par 1 personne
9,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Date et Heure Niveau :Initié Date de création :30/06/2004 Vu :6 752

Auteur : p0236

Ecrire un message privé
Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
Programme qui simule le TC (TimeCode), c'est le chronometre utilisé dans l'audio-visuel. Il est de la forme hh:mm:ss:ff
(hh : heure, mm : minute, ss : seconde, ff : frame)

Car en audio-visuel le nb de frame (image par seconde) est important, il est au nombre de 25 image par seconde, de 0 à 24, la p^remiere image etant le 0.

Source

  • package canal8 ;
  • import java.text.DecimalFormat;
  • class TimeCode extends Thread
  • {
  • private Interface obj ;
  • private boolean arreterThread = false ;
  • private int ff = 0 ;
  • private int ss = 0 ;
  • private int mm = 0 ;
  • private int hh = 0 ;
  • public TimeCode(Interface obj)
  • {
  • this.obj = obj ;
  • }
  • public void run()
  • {
  • while(!arreterThread) // permet d'arreter le thread en cours
  • {
  • for(int i=0 ; i < 2160000 ; i++)
  • {
  • try
  • {
  • this.sleep(40);//25 images par seconde
  • }
  • catch(InterruptedException e)
  • {
  • System.out.println("Systeme interrompu" + e);
  • }
  • if(ff <= 25)
  • ff++ ;
  • if((ss <=59) && (ff == 25))
  • {
  • ff = 0 ;
  • ss++ ;
  • }
  • if((mm < 59)&& (ss == 59))
  • {
  • ss = 0;
  • mm++ ;
  • }
  • if((hh < 24) && (mm == 59))
  • {
  • mm = 0 ;
  • hh++ ;
  • }
  • afficher(ff, ss, mm, hh) ;//appelle de la methode d'affichage
  • }
  • try
  • {
  • this.sleep(4000l);
  • }
  • catch(InterruptedException e)
  • {
  • System.out.println(e);
  • }
  • }
  • }
  • /*
  • *Cette fonction permet de <b></b>
  • *@param
  • *@return
  • */
  • public void afficher(int ff, int ss, int mm, int hh)
  • {
  • // %.2i
  • DecimalFormat f = new DecimalFormat("00") ;
  • obj.TCGeneral.setText(f.format(hh) +" : " + f.format(mm)
  • + " : " + f.format(ss) +" : " + f.format(ff) );
  • }
  • /*
  • *Cette fonction permet de <b></b>
  • *@param
  • *@return
  • */
  • public void init()
  • {
  • obj.TCGeneral.setText("00 : 00 : 00 : 00");
  • }
  • /*
  • *Cette fonction permet de <b></b>
  • *@param
  • *@return
  • */
  • public void lancer()
  • {
  • //si l'objet vient d'etre initialisé
  • /*if(arreterThread == true)
  • arreterThread = false ;
  • else*/
  • this.start() ;
  • //sinon
  • //
  • }
  • /*
  • *Cette fonction permet de <b></b>
  • *@param
  • *@return
  • */
  • public void arreter()
  • {
  • this.notify() ;
  • //arreterThread = true ;
  • }
  • /*
  • *Cette fonction permet de <b></b>
  • *@param
  • *@return
  • */
  • public TimeCode getValeur()
  • {
  • return this ;
  • }
  • /*
  • *Cette fonction permet de <b></b>
  • *@param
  • *@return
  • */
  • public void setValeur(TimeCode tc)
  • {
  • this.hh = tc.hh ;
  • this.mm = tc.mm ;
  • this.ss = tc.ss ;
  • this.ff = tc.ff ;
  • }
  • /*
  • *Cette fonction permet de <b></b>
  • *@param
  • *@return
  • */
  • int comparer(TimeCode t)
  • {
  • // on compare l'objet en parametre avec le this
  • // return 1 si t > this
  • // return 0 si t = this
  • // return -1 si t < this
  • int retour = 2 ; // valeur lambda
  • int valThis = this.recupereValeur() ;
  • int valT = t.recupereValeur() ;
  • if (valT > valThis)
  • retour = 1 ;
  • if (valT == valThis)
  • retour = 0 ;
  • if (valT < valThis)
  • retour = -1 ;
  • return (retour) ;
  • }
  • /*
  • *Cette fonction permet de <b></b>
  • *@param
  • *@return
  • */
  • int recupereValeur()
  • {
  • // donne la valeur en nombre de frame
  • // pour pouvoir faire une comparaison
  • int heure = this.hh ;
  • int minute = this.mm ;
  • int seconde = this.ss ;
  • int frame = this.ff ;
  • int nbFrame = ff + (ss * 25) + (mm * 60 * 25) + (hh * 60 * 60 * 25) ;
  • return (nbFrame) ;
  • }
  • }
package canal8 ;


import java.text.DecimalFormat;

class TimeCode extends Thread
{
	private Interface obj ;

	private boolean arreterThread = false ;

	private int ff = 0 ;
	private int ss = 0 ;
	private int mm = 0 ;
	private int hh = 0 ;

	public TimeCode(Interface obj)
	{
		this.obj = obj ;
	}

	public void run()
	{
		while(!arreterThread) // permet d'arreter le thread en cours
		{


			for(int i=0 ; i < 2160000 ; i++)
			{
				try
				{
					this.sleep(40);//25 images par seconde
				}
				catch(InterruptedException e)
				{
					System.out.println("Systeme interrompu" + e);
				}

				if(ff <= 25)
					ff++ ;

				if((ss <=59) && (ff == 25))
				{
					ff = 0 ;
					ss++ ;
				}
				if((mm < 59)&& (ss == 59))
				{
					ss = 0;
					mm++ ;
				}
				if((hh < 24) && (mm == 59))
				{
					mm = 0 ;
					hh++ ;
				}
				afficher(ff, ss, mm, hh) ;//appelle de la methode d'affichage
			}

			try
			{
				this.sleep(4000l);
			}
			catch(InterruptedException e)
			{
				System.out.println(e);
			}
		}
	}

	/*
	*Cette fonction permet de <b></b>
	*@param
	*@return
	*/
	public void afficher(int ff, int ss, int mm, int hh)
	{
		// %.2i
		DecimalFormat f = new DecimalFormat("00") ;

		obj.TCGeneral.setText(f.format(hh) +" : " + f.format(mm)
								+ " : " + f.format(ss) +" : " + f.format(ff) );
	}

	/*
	*Cette fonction permet de <b></b>
	*@param
	*@return
	*/
	public void init()
	{
		obj.TCGeneral.setText("00 : 00 : 00 : 00");
	}

	/*
	*Cette fonction permet de <b></b>
	*@param
	*@return
	*/
	public void lancer()
	{
		//si l'objet vient d'etre initialisé
		/*if(arreterThread == true)
			arreterThread = false ;
		else*/
			this.start() ;
		//sinon
			//

	}

	/*
	*Cette fonction permet de <b></b>
	*@param
	*@return
	*/
	public void arreter()
	{
		this.notify() ;
		//arreterThread = true ;
	}

	/*
	*Cette fonction permet de <b></b>
	*@param
	*@return
	*/
	public TimeCode getValeur()
	{
		return this ;
	}

	/*
	*Cette fonction permet de <b></b>
	*@param
	*@return
	*/
	public void setValeur(TimeCode tc)
	{
		this.hh = tc.hh ;
		this.mm = tc.mm ;
		this.ss = tc.ss ;
		this.ff = tc.ff ;
	}

	/*
	*Cette fonction permet de <b></b>
	*@param
	*@return
	*/
	int comparer(TimeCode t)
	{
		// on compare l'objet en parametre avec le this

		// return 1 si t > this
		// return 0 si t = this
		// return -1 si t < this

		int retour = 2 ; // valeur lambda

		int valThis	= this.recupereValeur() ;
		int valT	= t.recupereValeur() ;

		if (valT > valThis)
			retour = 1 ;

		if (valT == valThis)
			retour = 0 ;

		if (valT < valThis)
			retour = -1 ;

		return (retour) ;

	}

	/*
	*Cette fonction permet de <b></b>
	*@param
	*@return
	*/
	int recupereValeur()
	{
		// donne la valeur en nombre de frame
		// pour pouvoir faire une comparaison
		int heure 	= this.hh ;
		int minute	= this.mm ;
		int seconde	= this.ss ;
		int frame 	= this.ff ;

		int nbFrame = ff + (ss * 25) + (mm * 60 * 25) + (hh * 60 * 60 * 25) ;

		return (nbFrame) ;
	}
}



 Sources du même auteur

IMAGE D'INTRODUCTION

 Sources de la même categorie

Source avec Zip CHRONOMETRE par didoux95
Source avec Zip CHRONOMETRE SEC + CENTIEMES par z bozzo
LES JOURS FERIES MOBILES DES ANNÉES À VENIR par yvkoe
Source avec Zip Source avec une capture COMMANDE "CAL" SOUS *UX par dje_jay
OBTENIR DATE ET HEURE par danimo

Commentaires et avis

Commentaire de guiM47 le 07/06/2007 10:11:02

ca sert a quoi de mettre 200 lignes de codes sources ?

 Ajouter un commentaire




Nos sponsors


Appels d'offres

Sondage...

Comparez les prix


HTC Magic

Entre 429€ et 429€

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,359 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales