begin process at 2012 02 10 17:47:31
  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 :8 297

Auteur : p0236

Ecrire un message privé
Commentaire sur cette source (2)
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

[JAVA] INTERVALLE ENTRE 2 DATES SANS COMPTER LES WEEKENDS par rodriguezc
TRAVAILLER AVEC DES JOURS/HEURES/MINUTES/SECONDES par FreddyONE73
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

Commentaires et avis

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

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

Commentaire de borisnyasse le 17/02/2010 14:26:21

Serait il possible d'avoir le zip du projet ? Merci

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
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 : 9,391 sec (3)

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