Esempio n. 1
0
def recording(request, uuid, title=None):
    recording = get_object_or_404(Recording, mbid=uuid)

    show_restricted = False
    if recording.is_restricted() and request.show_bootlegs:
        show_restricted = True
    elif recording.is_restricted() and not request.show_bootlegs:
        raise Http404

    try:
        wave = docserver.util.docserver_get_url(
            recording.mbid,
            "audioimages",
            "waveform32",
            1,
            version=settings.FEAT_VERSION_IMAGE)
    except docserver.util.NoFileException:
        wave = None
    try:
        spec = docserver.util.docserver_get_url(
            recording.mbid,
            "audioimages",
            "spectrum32",
            1,
            version=settings.FEAT_VERSION_IMAGE)
    except docserver.util.NoFileException:
        spec = None
    try:
        small = docserver.util.docserver_get_url(
            recording.mbid,
            "audioimages",
            "smallfull",
            version=settings.FEAT_VERSION_IMAGE)
    except docserver.util.NoFileException:
        small = None
    try:
        audio = docserver.util.docserver_get_mp3_url(recording.mbid)
    except docserver.util.NoFileException:
        audio = None
    try:
        tonic = docserver.util.docserver_get_contents(
            recording.mbid,
            "carnaticvotedtonic",
            "tonic",
            version=settings.FEAT_VERSION_TONIC)
        notenames = [
            "A", "A♯", "B", "C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯"
        ]
        tonic = round(float(tonic), 2)
        thebin = (12 * math.log(tonic / 440.0) / math.log(2)) % 12
        thebin = int(round(thebin))
        tonic = str(tonic)
        if thebin <= 11 and thebin >= 0:
            tonicname = notenames[thebin]
        else:
            tonicname = ""
    except docserver.util.NoFileException:
        tonic = None
        tonicname = None
    try:
        akshara = docserver.util.docserver_get_contents(
            recording.mbid,
            "rhythm",
            "aksharaPeriod",
            version=settings.FEAT_VERSION_RHYTHM)
        akshara = str(round(float(akshara), 3) * 1000)
    except docserver.util.NoFileException:
        akshara = None

    try:
        pitchtrackurl = docserver.util.docserver_get_url(
            recording.mbid,
            "carnaticnormalisedpitch",
            "packedpitch",
            version=settings.FEAT_VERSION_CARNATIC_NORMALISED_PITCH)
        pitchtrackurl = request.build_absolute_uri(pitchtrackurl)
        histogramurl = docserver.util.docserver_get_url(
            recording.mbid,
            "carnaticnormalisedpitch",
            "drawhistogram",
            version=settings.FEAT_VERSION_CARNATIC_NORMALISED_PITCH)
        histogramurl = request.build_absolute_uri(histogramurl)
    except docserver.util.NoFileException:
        pitchtrackurl = ""
        histogramurl = ""

    try:
        rhythmurl = docserver.util.docserver_get_url(
            recording.mbid,
            "rhythm",
            "aksharaTicks",
            version=settings.FEAT_VERSION_RHYTHM)
        rhythmurl = request.build_absolute_uri(rhythmurl)
        aksharaurl = docserver.util.docserver_get_url(
            recording.mbid,
            "rhythm",
            "APcurve",
            version=settings.FEAT_VERSION_RHYTHM)
        aksharaurl = request.build_absolute_uri(aksharaurl)
    except docserver.util.NoFileException:
        rhythmurl = ""
        aksharaurl = ""

    similar = []
    try:
        similar_mbids = search.similar_recordings(recording.mbid)
        for m in similar_mbids:
            try:
                rec = Recording.objects.get(mbid=m[0])
                similar.append(rec)
            except Recording.DoesNotExist:
                pass
    except pysolr.SolrError:
        # TODO: Show error in similar recordings page instead of empty
        pass
    similar = similar[:10]

    try:
        permission = utils.get_user_permissions(request.user)
        concert = recording.concert_set.with_permissions(
            None, permission=permission).get()
        recordings = list(concert.recordings.all())
        recordingpos = recordings.index(recording)
    except Concert.DoesNotExist:
        concert = None
        recordings = []
        recordingpos = 0
    nextrecording = None
    prevrecording = None
    if recordingpos > 0:
        prevrecording = recordings[recordingpos - 1]
    if recordingpos + 1 < len(recordings):
        nextrecording = recordings[recordingpos + 1]
    mbid = recording.mbid

    ret = {
        "filter_items": json.dumps(get_filter_items()),
        "recording": recording,
        "objecttype": "recording",
        "objectid": recording.id,
        "waveform": wave,
        "spectrogram": spec,
        "smallimage": small,
        "audio": audio,
        "tonic": tonic,
        "tonicname": tonicname,
        "akshara": akshara,
        "mbid": mbid,
        "nextrecording": nextrecording,
        "prevrecording": prevrecording,
        "pitchtrackurl": pitchtrackurl,
        "histogramurl": histogramurl,
        "rhythmurl": rhythmurl,
        "aksharaurl": aksharaurl,
        "similar": similar,
        "concert": concert,
        "bootleg": show_restricted,
    }

    return render(request, "carnatic/recording.html", ret)
Esempio n. 2
0
def recording(request, uuid, title=None):
    recording = get_object_or_404(Recording, mbid=uuid)

    show_restricted = False
    if recording.is_restricted() and request.show_bootlegs:
        show_restricted = True
    elif recording.is_restricted() and not request.show_bootlegs:
        raise Http404

    try:
        wave = docserver.util.docserver_get_url(recording.mbid, "audioimages", "waveform32", 1, version=settings.FEAT_VERSION_IMAGE)
    except docserver.exceptions.NoFileException:
        wave = None
    try:
        spec = docserver.util.docserver_get_url(recording.mbid, "audioimages", "spectrum32", 1, version=settings.FEAT_VERSION_IMAGE)
    except docserver.exceptions.NoFileException:
        spec = None
    try:
        small = docserver.util.docserver_get_url(recording.mbid, "audioimages", "smallfull", version=settings.FEAT_VERSION_IMAGE)
    except docserver.exceptions.NoFileException:
        small = None
    try:
        audio = docserver.util.docserver_get_mp3_url(recording.mbid)
    except docserver.exceptions.NoFileException:
        audio = None
    try:
        tonic = docserver.util.docserver_get_contents(recording.mbid, "carnaticvotedtonic", "tonic", version=settings.FEAT_VERSION_TONIC)
        notenames = ["A", "A♯", "B", "C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯"]
        tonic = round(float(tonic), 2)
        thebin = (12 * math.log(tonic / 440.0) / math.log(2)) % 12
        thebin = int(round(thebin))
        tonic = str(tonic)
        if thebin <= 11 and thebin >= 0:
            tonicname = notenames[thebin]
        else:
            tonicname = ""
    except docserver.exceptions.NoFileException:
        tonic = None
        tonicname = None
    try:
        akshara = docserver.util.docserver_get_contents(recording.mbid, "rhythm", "aksharaPeriod", version=settings.FEAT_VERSION_RHYTHM)
        akshara = str(round(float(akshara), 3) * 1000)
    except docserver.exceptions.NoFileException:
        akshara = None

    try:
        pitchtrackurl = docserver.util.docserver_get_url(recording.mbid, "carnaticnormalisedpitch", "packedpitch", version=settings.FEAT_VERSION_CARNATIC_NORMALISED_PITCH)
        pitchtrackurl = request.build_absolute_uri(pitchtrackurl)
        histogramurl = docserver.util.docserver_get_url(recording.mbid, "carnaticnormalisedpitch", "drawhistogram", version=settings.FEAT_VERSION_CARNATIC_NORMALISED_PITCH)
        histogramurl = request.build_absolute_uri(histogramurl)
    except docserver.exceptions.NoFileException:
        pitchtrackurl = ""
        histogramurl = ""

    try:
        rhythmurl = docserver.util.docserver_get_url(recording.mbid, "rhythm", "aksharaTicks", version=settings.FEAT_VERSION_RHYTHM)
        rhythmurl = request.build_absolute_uri(rhythmurl)
        aksharaurl = docserver.util.docserver_get_url(recording.mbid, "rhythm", "APcurve", version=settings.FEAT_VERSION_RHYTHM)
        aksharaurl = request.build_absolute_uri(aksharaurl)
    except docserver.exceptions.NoFileException:
        rhythmurl = ""
        aksharaurl = ""

    similar = []
    try:
        similar_mbids = search.similar_recordings(recording.mbid)
        for m in similar_mbids:
            try:
                rec = Recording.objects.get(mbid=m[0])
                similar.append(rec)
            except Recording.DoesNotExist:
                pass
    except pysolr.SolrError:
        # TODO: Show error in similar recordings page instead of empty
        pass
    similar = similar[:10]

    try:
        permission = utils.get_user_permissions(request.user)
        concert = recording.concert_set.with_permissions(None, permission=permission).get()
        recordings = list(concert.recordings.all())
        recordingpos = recordings.index(recording)
    except Concert.DoesNotExist:
        concert = None
        recordings = []
        recordingpos = 0
    nextrecording = None
    prevrecording = None
    if recordingpos > 0:
        prevrecording = recordings[recordingpos - 1]
    if recordingpos + 1 < len(recordings):
        nextrecording = recordings[recordingpos + 1]
    mbid = recording.mbid

    ret = {"recording": recording,
           "objecttype": "recording",
           "objectid": recording.id,
           "waveform": wave,
           "spectrogram": spec,
           "smallimage": small,
           "audio": audio,
           "tonic": tonic,
           "tonicname": tonicname,
           "akshara": akshara,
           "mbid": mbid,
           "nextrecording": nextrecording,
           "prevrecording": prevrecording,
           "pitchtrackurl": pitchtrackurl,
           "histogramurl": histogramurl,
           "rhythmurl": rhythmurl,
           "aksharaurl": aksharaurl,
           "similar": similar,
           "concert": concert,
           "bootleg": show_restricted,
           }

    return render(request, "carnatic/recording.html", ret)
Esempio n. 3
0
def recording(request, uuid, title=None):
    recording = get_object_or_404(Recording, mbid=uuid)

    bootleg = False
    if recording.is_bootleg() and request.show_bootlegs:
        bootleg = True
    elif recording.is_bootleg() and not request.show_bootlegs:
        raise Http404

    tags = tagging.tag_cloud(recording.id, "recording")

    try:
        wave = docserver.util.docserver_get_url(recording.mbid, "audioimages", "waveform32", 1, version=settings.FEAT_VERSION_IMAGE)
    except docserver.util.NoFileException:
        wave = None
    try:
        spec = docserver.util.docserver_get_url(recording.mbid, "audioimages", "spectrum32", 1, version=settings.FEAT_VERSION_IMAGE)
    except docserver.util.NoFileException:
        spec = None
    try:
        small = docserver.util.docserver_get_url(recording.mbid, "audioimages", "smallfull", version=settings.FEAT_VERSION_IMAGE)
    except docserver.util.NoFileException:
        small = None
    try:
        audio = docserver.util.docserver_get_mp3_url(recording.mbid)
    except docserver.util.NoFileException:
        audio = None
    try:
        tonic = docserver.util.docserver_get_contents(recording.mbid, "votedtonic", "tonic", version=settings.FEAT_VERSION_TONIC)
        notenames = ["A", "A♯", "B", "C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯"]
        tonic = round(float(tonic), 2)
        thebin = (12 * math.log(tonic / 440.0) / math.log(2)) % 12
        thebin = int(round(thebin))
        tonic = str(tonic)
        if thebin <= 11 and thebin >= 0:
            tonicname = notenames[thebin]
        else:
            print "bin is", thebin, "weird"
            print tonic
            tonicname = ""
    except docserver.util.NoFileException:
        tonic = None
        tonicname = None
    try:
        akshara = docserver.util.docserver_get_contents(recording.mbid, "rhythm", "aksharaPeriod", version=settings.FEAT_VERSION_RHYTHM)
        akshara = str(round(float(akshara), 3) * 1000)
    except docserver.util.NoFileException:
        akshara = None

    try:
        pitchtrackurl = docserver.util.docserver_get_url(recording.mbid, "normalisedpitch", "packedpitch", version=settings.FEAT_VERSION_NORMALISED_PITCH)
        histogramurl = docserver.util.docserver_get_url(recording.mbid, "normalisedpitch", "drawhistogram", version=settings.FEAT_VERSION_NORMALISED_PITCH)
        rhythmurl = docserver.util.docserver_get_url(recording.mbid, "rhythm", "aksharaTicks", version=settings.FEAT_VERSION_RHYTHM)
        aksharaurl = docserver.util.docserver_get_url(recording.mbid, "rhythm", "APcurve", version=settings.FEAT_VERSION_RHYTHM)
    except docserver.util.NoFileException:
        pitchtrackurl = "/document/by-id/%s/%s?subtype=%s&v=%s" % (recording.mbid, "normalisedpitch", "packedpitch", settings.FEAT_VERSION_NORMALISED_PITCH)
        histogramurl = "/document/by-id/%s/%s?subtype=%s&v=%s" % (recording.mbid, "normalisedpitch", "drawhistogram", settings.FEAT_VERSION_NORMALISED_PITCH)
        rhythmurl = "/document/by-id/%s/%s?subtype=%s&v=%s" % (recording.mbid, "rhythm", "aksharaTicks", settings.FEAT_VERSION_RHYTHM)
        aksharaurl = "/document/by-id/%s/%s?subtype=%s&v=%s" % (recording.mbid, "rhythm", "APcurve", settings.FEAT_VERSION_RHYTHM)

    similar = []
    try:
        similar_mbids = search.similar_recordings(recording.mbid)
        for m in similar_mbids:
            try:
                rec = Recording.objects.get(mbid=m[0])
                similar.append(rec)
            except Recording.DoesNotExist:
                pass
    except pysolr.SolrError:
        # TODO: Show error in similar recordings page instead of empty
        pass
    similar = similar[:10]

    try:
        concert = recording.concert_set.get()
        recordings = list(concert.recordings.all())
        recordingpos = recordings.index(recording)
    except Concert.DoesNotExist:
        concert = None
        recordings = []
        recordingpos = 0
    nextrecording = None
    prevrecording = None
    if recordingpos > 0:
        prevrecording = recordings[recordingpos - 1]
    if recordingpos + 1 < len(recordings):
        nextrecording = recordings[recordingpos + 1]
    mbid = recording.mbid

    ret = {"filter_items": json.dumps(get_filter_items()),
           "recording": recording,
           "form": TagSaveForm(),
           "objecttype": "recording",
           "objectid": recording.id,
           "tags": tags,
           "waveform": wave,
           "spectrogram": spec,
           "smallimage": small,
           "audio": audio,
           "tonic": tonic,
           "tonicname": tonicname,
           "akshara": akshara,
           "mbid": mbid,
           "nextrecording": nextrecording,
           "prevrecording": prevrecording,
           "pitchtrackurl": pitchtrackurl,
           "histogramurl": histogramurl,
           "rhythmurl": rhythmurl,
           "aksharaurl": aksharaurl,
           "similar": similar,
           "concert": concert,
           "bootleg": bootleg,
           }

    return render(request, "carnatic/recording.html", ret)
Esempio n. 4
0
def recording(request, uuid):
    recording = get_object_or_404(Recording, mbid=uuid)

    tags = tagging.tag_cloud(recording.id, "recording")

    try:
        wave = docserver.util.docserver_get_url(recording.mbid, "audioimages", "waveform32", 1)
    except docserver.util.NoFileException:
        wave = None
    try:
        spec = docserver.util.docserver_get_url(recording.mbid, "audioimages", "spectrum32", 1)
    except docserver.util.NoFileException:
        spec = None
    try:
        small = docserver.util.docserver_get_url(recording.mbid, "audioimages", "smallfull")
    except docserver.util.NoFileException:
        small = None
    try:
        audio = docserver.util.docserver_get_mp3_url(recording.mbid)
    except docserver.util.NoFileException:
        audio = None
    try:
        tonic = docserver.util.docserver_get_contents(recording.mbid, "ctonic", "tonic")
        notenames = ["A", "A♯", "B", "C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯"]
        tonic = round(float(tonic), 2)
        thebin = (12 * math.log(tonic/440.0) / math.log(2)) % 12
        thebin = int(round(thebin))
        tonic = str(tonic)
        if thebin <= 11 and thebin >= 0:
            tonicname = notenames[thebin]
        else:
            print "bin is", thebin, "weird"
            print tonic
            tonicname = ""
    except docserver.util.NoFileException:
        tonic = None
        tonicname = None
    try:
        akshara = docserver.util.docserver_get_contents(recording.mbid, "rhythm", "aksharaPeriod")
        akshara = str(round(float(akshara), 3) * 1000)
    except docserver.util.NoFileException:
        akshara = None

    try:
        pitchtrackurl = docserver.util.docserver_get_url(recording.mbid, "normalisedpitch", "packedpitch")
        histogramurl = docserver.util.docserver_get_url(recording.mbid, "normalisedpitch", "drawhistogram")
        rhythmurl = docserver.util.docserver_get_url(recording.mbid, "rhythm", "aksharaTicks")
        aksharaurl = docserver.util.docserver_get_url(recording.mbid, "rhythm", "APcurve")
    except docserver.util.NoFileException:
        pitchtrackurl = None
        histogramurl = None
        rhythmurl = None
        aksharaurl = None

    similar = []
    try:
        similar_mbids = search.similar_recordings(recording.mbid)
        for m in similar_mbids:
            rec = Recording.objects.get(mbid=m[0])
            similar.append(rec)
    except pysolr.SolrError:
        # TODO: Show error in similar recordings page instead of empty
        pass
    similar = similar[:10]

    try:
        concert = recording.concert_set.get()
        tracks = list(concert.tracks.all())
        recordingpos = tracks.index(recording)
    except Concert.DoesNotExist:
        concert = None
        tracks = []
        recordingpos = 0
    nextrecording = None
    prevrecording = None
    if recordingpos > 0:
        prevrecording = tracks[recordingpos-1]
    if recordingpos+1 < len(tracks):
        nextrecording = tracks[recordingpos+1]
    mbid = recording.mbid

    ret = {"filter_items": json.dumps(get_filter_items()),
    	   "recording": recording,
           "form": TagSaveForm(),
            "objecttype": "recording",
            "objectid": recording.id,
            "tags": tags,
            "waveform": wave,
            "spectrogram": spec,
            "smallimage": small,
            "audio": audio,
            "tonic": tonic,
            "tonicname": tonicname,
            "akshara": akshara,
            "mbid": mbid,
            "nextrecording": nextrecording,
            "prevrecording": prevrecording,
            "pitchtrackurl": pitchtrackurl,
            "histogramurl": histogramurl,
            "rhythmurl": rhythmurl,
            "aksharaurl": aksharaurl,
            "similar": similar,
            "concert": concert,
    }

    return render(request, "carnatic/recording.html", ret)