Exemplo n.º 1
0
	def resultForBasicToneExistAtHead(self, runs):

		contiguousRuns = self.contiguousRuns(runs)
		result = False

		for run in contiguousRuns:
			zoneStart = convertTimeCodeToUnsignedLongLong("00:57:30:00",self.timeCodeSampleRate, self.timeBase)
			zoneStop = convertTimeCodeToUnsignedLongLong("00:58:31:00",self.timeCodeSampleRate, self.timeBase)

			runStart = convertUnsignedLongLongToTimeCode(run['start'], self.timeCodeSampleRate, self.timeBase)
			runStop = convertUnsignedLongLongToTimeCode(run['start']+ (run['length']*self.timeCodeSampleRate), self.timeCodeSampleRate, self.timeBase)
			runLength = run['length']

			if runStart >= zoneStart and runStop <= runStop and runLength >= 54:
				
				runsToCheck = runs[runs.index(run):run['length']]
				runsToCheck = runsToCheck[1:-1]
				doesRunHaveTheCorrectLevelResultString = self.descriptionForLevelsInRuns(runsToCheck)

				if doesRunHaveTheCorrectLevelResultString != 'success':
					return {"status":"fail", "resultString":doesRunHaveTheCorrectLevelResultString}
				else:
					return {"status":"pass"}

		description = ""
		if len(contiguousRuns) > 0:
			description = "No proper 1kHz tones were found, only 1kHz tones with the following lengths in seconds: {}.".format(" ".join([str(run['length']) for run in contiguousRuns]))
		else:
			description = "No proper 1kHz tones were found."

		return {"status":"fail", "resultString":description}
Exemplo n.º 2
0
def smallSampleSize():

    try:
        filePath = sys.argv[1]
        if os.path.exists(filePath):
            wavefile = PCWaveFile(filePath)

            if wavefile.isValidWaveFile() != True:
                print "File is not a wave file"
                return

            dataStartPos = wavefile.getDataChunk()["chunkPosition"]
            dataLength = wavefile.getDataChunk()["chunkSize"]
            sampleRate = wavefile.numberOfSamplesPerSecond()
            timeCodeSampleRate = int(sampleRate * 1.001)
            byteWidth = wavefile.numberOfBytesPerSample()
            numberOfChannels = wavefile.numberOfChannels()

            frameNumber = 0
            print datetime.datetime.now()
            with open(filePath, 'rb') as f:
                startTime = datetime.datetime.now()
                f.seek(dataStartPos)
                data_size = int(
                    (sampleRate * 1.001) /
                    24)  #1 frame of audio at 23.98 or 48048 sample rate

                dataToReadChunkSize = data_size * byteWidth
                #examine 160 seconds of data
                dataRemaining = (160 * timeCodeSampleRate
                                 ) * byteWidth * numberOfChannels  #dataLength

                while dataRemaining > 0:
                    if dataRemaining > dataToReadChunkSize:
                        data = f.read(dataToReadChunkSize)
                    else:
                        data = f.read(dataRemaining)

                    dataRemaining -= len(data)

                    print pctimecode.convertUnsignedLongLongToTimeCode(
                        wavefile.timestamp + (frameNumber * data_size),
                        timeCodeSampleRate, 24)
                    frameNumber += 1

                    for channel in range(0, numberOfChannels):
                        subdata = ""
                        for x in range(channel * byteWidth, len(data),
                                       byteWidth * numberOfChannels):
                            # subdata.extend(data[x:x+3])
                            subdata += (data[x] + data[x + 1] + data[x + 2])

                        print ultimateFreqAndPowerForData(
                            subdata, byteWidth, sampleRate)

            print datetime.datetime.now()
        else:
            print "The file", filename, "doesn't exist"
    except IndexError as e:
        print "No file was passed in as a variable"
Exemplo n.º 3
0
def multichannel():

    try:
        filePath = sys.argv[1]
        if os.path.exists(filePath):
            wavefile = PCWaveFile(filePath)

            if wavefile.isValidWaveFile() != True:
                print "File is not a wave file"
                return

            dataStartPos = wavefile.getDataChunk()["chunkPosition"]
            dataLength = wavefile.getDataChunk()["chunkSize"]
            sampleRate = wavefile.numberOfSamplesPerSecond()
            timeCodeSampleRate = int(math.ceil(48000 * 1.001))
            byteWidth = wavefile.numberOfBytesPerSample()
            numberOfChannels = wavefile.numberOfChannels()
            data_size = 48048  #1 second of audio

            print timeCodeSampleRate
            print pctimecode.convertUnsignedLongLongToTimeCode(
                wavefile.timestamp, timeCodeSampleRate, 24)

            second = 0
            with open(filePath, 'rb') as f:
                startTime = datetime.datetime.now()
                f.seek(dataStartPos)

                dataToReadChunkSize = sampleRate * byteWidth * numberOfChannels
                dataRemaining = dataLength

                while dataRemaining > 0:
                    if dataRemaining > dataToReadChunkSize:
                        data = f.read(dataToReadChunkSize)
                    else:
                        data = f.read(dataRemaining)

                    dataRemaining -= len(data)

                    print wavefile.timestamp
                    print pctimecode.convertUnsignedLongLongToTimeCode(
                        wavefile.timestamp + (second * data_size),
                        timeCodeSampleRate, 24)
                    for channel in range(0, numberOfChannels):
                        subdata = ""
                        for x in range(channel * byteWidth, len(data),
                                       byteWidth * numberOfChannels):
                            subdata += (data[x] + data[x + 1] + data[x + 2])

                        print highestAndNextHighestFreqAndPowerForData(
                            subdata, byteWidth, sampleRate)

                    second += 1

        else:
            print "The file", filename, "doesn't exist"
    except IndexError as e:
        print "No file was passed in as a variable"
Exemplo n.º 4
0
def smallSampleSize():

    try:
        filePath = sys.argv[1]
        if os.path.exists(filePath):
            wavefile = PCWaveFile(filePath)

            if wavefile.isValidWaveFile() != True:
                print "File is not a wave file"
                return

            dataStartPos = wavefile.getDataChunk()["chunkPosition"]
            dataLength = wavefile.getDataChunk()["chunkSize"]
            sampleRate = wavefile.numberOfSamplesPerSecond()
            timeCodeSampleRate = int(sampleRate *  1.001)
            byteWidth = wavefile.numberOfBytesPerSample()
            numberOfChannels = wavefile.numberOfChannels()

            frameNumber = 0
            print datetime.datetime.now()
            with open(filePath, 'rb') as f:
                startTime = datetime.datetime.now()
                f.seek(dataStartPos)
                data_size = int((sampleRate * 1.001) / 24) #1 frame of audio at 23.98 or 48048 sample rate

                dataToReadChunkSize = data_size*byteWidth
                #examine 160 seconds of data
                dataRemaining = (160*timeCodeSampleRate)*byteWidth*numberOfChannels #dataLength
               
                while dataRemaining > 0:
                    if dataRemaining > dataToReadChunkSize:
                        data = f.read(dataToReadChunkSize)
                    else:
                        data = f.read(dataRemaining)

                    dataRemaining -= len(data)

                    print pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp + (frameNumber * data_size), timeCodeSampleRate, 24)
                    frameNumber += 1

                    for channel in range(0, numberOfChannels):
                        subdata = ""
                        for x in range(channel*byteWidth,len(data),byteWidth*numberOfChannels):
                            # subdata.extend(data[x:x+3])
                            subdata += (data[x] + data[x+1] + data[x+2])

                        print ultimateFreqAndPowerForData(subdata, byteWidth, sampleRate)

            print datetime.datetime.now()
        else:
            print "The file",filename,"doesn't exist"
    except IndexError as e:
        print "No file was passed in as a variable"     
Exemplo n.º 5
0
def multichannel():
    
    try:
        filePath = sys.argv[1]
        if os.path.exists(filePath):
            wavefile = PCWaveFile(filePath)

            if wavefile.isValidWaveFile() != True:
                print "File is not a wave file"
                return

            dataStartPos = wavefile.getDataChunk()["chunkPosition"]
            dataLength = wavefile.getDataChunk()["chunkSize"]
            sampleRate = wavefile.numberOfSamplesPerSecond()
            timeCodeSampleRate = int(math.ceil(48000 * 1.001))
            byteWidth = wavefile.numberOfBytesPerSample()
            numberOfChannels = wavefile.numberOfChannels()
            data_size = 48048 #1 second of audio

            print timeCodeSampleRate
            print pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp, timeCodeSampleRate, 24)

            second = 0
            with open(filePath, 'rb') as f:
                startTime = datetime.datetime.now()
                f.seek(dataStartPos)

                dataToReadChunkSize = sampleRate*byteWidth*numberOfChannels
                dataRemaining = dataLength
               
                while dataRemaining > 0:
                    if dataRemaining > dataToReadChunkSize:
                        data = f.read(dataToReadChunkSize)
                    else:
                        data = f.read(dataRemaining)

                    dataRemaining -= len(data)

                    print wavefile.timestamp
                    print pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp + (second * data_size), timeCodeSampleRate, 24)
                    for channel in range(0, numberOfChannels):
                        subdata = ""
                        for x in range(channel*byteWidth,len(data),byteWidth*numberOfChannels):
                            subdata += (data[x] + data[x+1] + data[x+2])

                        print highestAndNextHighestFreqAndPowerForData(subdata, byteWidth, sampleRate)

                    second += 1

        else:
            print "The file",filename,"doesn't exist"
    except IndexError as e:
        print "No file was passed in as a variable"         
Exemplo n.º 6
0
def listOfTimeCodeValuesForFile(fullpath):
	wavefile = PCWaveFile(fullpath)
	if wavefile.isValidWaveFile() == False:
		print 'File is not valid'
		return

	tcList = []
	sampleRate = wavefile.fmtChunkInfoDict['nSamplesPerSec']
	tcList.append(wavefile.timestamp)
	tcList.append(pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp, sampleRate*1.001, 24)) 	#23976
	tcList.append(pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp, sampleRate, 24))			#24
	tcList.append(pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp, sampleRate, 25))			#25
	tcList.append(pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp, sampleRate*1.001, 30)) 	#2997
	tcList.append(pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp, sampleRate, 30))			#30	
	return tcList	
Exemplo n.º 7
0
	def isPopRun(self, run, channel):
		correctRunStart = self.doesRunStartAtPopTime(run)
		correctRunFrequency = self.isRunAtTheCorrectFrequency(run)
		
		successfulResult = "Found a pop on channel {}".format(channel)
		status = "pass"
		currentError = ""
		resultString = successfulResult
		result = True

		if correctRunStart is False:
			timeStart = convertUnsignedLongLongToTimeCode(run["start"], self.timeCodeSampleRate, self.timeBase)
			currentError = "The pop on track {} start at {}. ".format(channel, timeStart)
			status = "fail"
			result = False

		if run["count"] != 1:
			currentError = currentError + "There doesn't appear to be a pop on channel {}".format(channel)
			status = "fail"
			result = False

		if correctRunFrequency is False:
			currentError = currentError + "The frequency of the pop on channel {} is not correct: {} Hz".format(channel, run["freq"])
			status = "fail"
			result = False

		if currentError is not "":
			resultString = currentError

		return tuple([result, {"status":status, "resultString":resultString}])
Exemplo n.º 8
0
def timeCodeDisplayTest(sampleRate=48000):
	try:
		filename = sys.argv[1]
		if os.path.exists(filename):
			wavefile = PCWaveFile(filename)
			print wavefile.filePath
			print "23.976\t\t", pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp, sampleRate*1.001, 24)
			print "24\t\t", pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp, sampleRate, 24)
			print "25\t\t", pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp, sampleRate, 25)
			print "29.97\t\t", pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp, sampleRate*1.001, 30)
			print "30\t\t", pctimecode.convertUnsignedLongLongToTimeCode(wavefile.timestamp, sampleRate, 30)	
			print wavefile.regnChunkInfoDict
			print wavefile.timestamp

		else:
			print "The file",filename,"doesn't exist"
	except:
		print "No file was passed in as a variable"
Exemplo n.º 9
0
    def resultForBasicToneExistAtHead(self, runs):

        contiguousRuns = self.contiguousRuns(runs)
        result = False

        for run in contiguousRuns:
            zoneStart = convertTimeCodeToUnsignedLongLong(
                "00:57:30:00", self.timeCodeSampleRate, self.timeBase)
            zoneStop = convertTimeCodeToUnsignedLongLong(
                "00:58:31:00", self.timeCodeSampleRate, self.timeBase)

            runStart = convertUnsignedLongLongToTimeCode(
                run['start'], self.timeCodeSampleRate, self.timeBase)
            runStop = convertUnsignedLongLongToTimeCode(
                run['start'] + (run['length'] * self.timeCodeSampleRate),
                self.timeCodeSampleRate, self.timeBase)
            runLength = run['length']

            if runStart >= zoneStart and runStop <= runStop and runLength >= 54:

                runsToCheck = runs[runs.index(run):run['length']]
                runsToCheck = runsToCheck[1:-1]
                doesRunHaveTheCorrectLevelResultString = self.descriptionForLevelsInRuns(
                    runsToCheck)

                if doesRunHaveTheCorrectLevelResultString != 'success':
                    return {
                        "status": "fail",
                        "resultString": doesRunHaveTheCorrectLevelResultString
                    }
                else:
                    return {"status": "pass"}

        description = ""
        if len(contiguousRuns) > 0:
            description = "No proper 1kHz tones were found, only 1kHz tones with the following lengths in seconds: {}.".format(
                " ".join([str(run['length']) for run in contiguousRuns]))
        else:
            description = "No proper 1kHz tones were found."

        return {"status": "fail", "resultString": description}
Exemplo n.º 10
0
	def isToneRun(self, run, channel):
		correctRunStart = self.doesToneRunStartAtCorrectTime(run)
		correctRunLength = self.isToneRunLongEnough(run)
		correctRunLevel = self.isRunTheProperToneLevel(run)
		correctRunFrequency = self.isRunAtTheCorrectFrequency(run)
		
		successfulResult = "The tracks contain 1 kHz tones for one minute"
		result = True
		status = "pass"
		currentError = ""
		resultString = successfulResult

		if correctRunStart is False:
			timeStart = convertUnsignedLongLongToTimeCode(run["start"], self.timeCodeSampleRate, self.timeBase)
			currentError = "The Tones on track {} start at {}. ".format(channel, timeStart)
			status = "fail"
			result = False

		if correctRunLength is False:
			currentError = currentError + "The Tones on track {} start are not in spec: {} seconds.".format(channel, run["count"])
			status = "fail"
			result = False

		if correctRunLevel is False:
			currentError = currentError + "The levels on track {} are not in spec: {} db.".format(channel, run["freqDBRep"])
			status = "fail"
			result = False

		if correctRunFrequency is False:
			currentError = currentError + "The frequency on track {} is not in spec: {} seconds.".format(channel, run["freq"])
			status = "fail"
			result = False

		if currentError is not "":
			resultString = currentError

		return tuple([result, {"status":status, "resultString":resultString}])
Exemplo n.º 11
0
    def result(self):

        status = "pass"
        resultString    = ""
        warningString   = ""
        successStrings  = []
        errorStrings    = []
        warningStrings  = []

        #does a pop exist at 00:59:58:00

        for channel in self.analysisDict.keys():

            # activityErrors, activityWarnings, additionalErrors = self.activityStatusForPopArea(self.analysisDict[channel])
            # if len(activityErrors) > 0:
            #     errorStrings.append("Found signal with a level of {} in the pop area on channel {}.".format(activityErrors, channel))
            # if len(activityWarnings) > 0:
            #     warningStrings.append("Found signal with a level of {} in the pop area on channel {}.".format(activityWarnings, channel))
            # if len(additionalErrors) > 0:
            #     errorStrings.append("Check the head pop area on channel {} as {}.".format(channel, " ".join(additionalErrors)))

            foundPop = False

            if self.doesAPopExistAtTheProperPlace(self.analysisDict[channel]) == False:
                #if the pop doesn't exist at 00:59:58:00, can we attempt to find it?
                errorStrings.append("No pop found at TimeCode 00:59:58:00 on channel {}.".format(channel))

                analysis = self.analysisOfLikelyPop(self.analysisDict[channel])
                
                tcvalue = convertUnsignedLongLongToTimeCode(analysis['timeStamp'], self.timeCodeSampleRate, self.timeBase)
                if self.isAnalysisFreqSafe(analysis) == True:
                    errorStrings.append("Found a pop on channel {} at the wrong location: {}.".format(channel, tcvalue))
                else:
                    freqValue = analysis['mainFreq']['freqHz']
                    if math.isnan(freqValue):
                        errorStrings.append("No discernable pop found on channel {}.".format(channel))
                    else:
                        errorStrings.append("Found signal on channel {} at the wrong location {} outside of 1 kHz.".format(channel, tcvalue))
            else:
                analysis = self.analysisAtPopLocation(self.analysisDict[channel])
                #make sure there is nothing else in the track
                foundPop = True
                if self.isAnalysisVolumeSafe(analysis) == True:
                    successStrings.append("A properly defined 1 kHz pop was found on channel {}.".format(channel))
                elif analysis['mainFreq']['dbRep'] < -23.3 and analysis['mainFreq']['dbRep'] > -28.0:
                    adjustedDb = analysis['mainFreq']['dbRep'] + 3.2
                    warningStrings.append('The pop on channel {} is a low level {:3.2f}db.'.format(channel, adjustedDb))
                elif analysis['mainFreq']['dbRep'] < -28.0:
                    adjustedDb = analysis['mainFreq']['dbRep'] + 3.2
                    errorStrings.append('The pop on channel {} is too low {:3.2f}db.'.format(channel, adjustedDb))
                elif analysis['mainFreq']['dbRep'] > -23.0:
                    adjustedDb = analysis['mainFreq']['dbRep'] + 3.2
                    warningStrings.append('The pop on channel {} is hot: {:3.2f}db.'.format(channel, adjustedDb))


        if len(errorStrings) > 0:
            status = "fail"
            resultString = resultString + " ".join(errorStrings)

        if len(warningStrings) > 0:
            warningString = " ".join(warningStrings)

        if len(successStrings) > 0:
            resultString = resultString + " " + " ".join(successStrings)

        if resultString == "":
            resultString = "All tracks have a well defined pop at 00:59:58:00."

        return {"status":status, "resultString":resultString, "warningString":warningString, "foundPop":("pass" if foundPop else 'fail')}
Exemplo n.º 12
0
 def analysisAtPopLocation(self, analyses):
     for analysis in analyses:
         if convertUnsignedLongLongToTimeCode(analysis['timeStamp'], self.timeCodeSampleRate, self.timeBase) == "00:59:58:00":
             return analysis
     
     return None
Exemplo n.º 13
0
def prettyTimeCode2398(timeStamp, sampleRate):
    pulledUpSampleRate = onePercentPullUp(sampleRate)
    return convertUnsignedLongLongToTimeCode(timeStamp, pulledUpSampleRate, 24)
Exemplo n.º 14
0
def prettyTimeCode2398(timeStamp, sampleRate):
	pulledUpSampleRate = onePercentPullUp(sampleRate)
	return convertUnsignedLongLongToTimeCode(timeStamp, pulledUpSampleRate, 24)