Skip to content
Snippets Groups Projects
Commit c86902d1 authored by jda92's avatar jda92
Browse files

buttons still in testing

parent bc0f46c6
No related branches found
No related tags found
1 merge request!4Developer
Showing
with 198 additions and 24 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
File added
File added
File added
File added
File added
No preview for this file type
No preview for this file type
No preview for this file type
from django import forms
"""class MyForm(forms.Form):
NAME_CHOICES = (('songName', 'name'),
'tempo', 'mid'))
name = forms.ChoiceField(choices=NAME_CHOICES)"""
class NameForm(forms.Form):
songName = forms.CharField(label='songName', max_length=100)
#tempo = forms.CharField(label='tempo', max_length=100)
#length = forms.CharField(label='length', max_length=100)
#instrument = forms.CharField(label='instrument', max_length=100)
tempo = forms.CharField(label="tempo", required=True)
length = forms.CharField(label="length", required=True)
instrument = forms.CharField(label="instrument", required=True)
scale = forms.CharField(label="instrument", required=True)
SCALE_CHOICES=(("major", "major"), ("minor", "minor"))
scalechoice = forms.ChoiceField(label="scalechoice", choices=SCALE_CHOICES)
#INTRUMENT_CHOICES=(("piano", "piano"), ("guitar", "guitar"), ("synth", "synth"), ("violin", "violin"), ("banjo", "banjo"))
#primaryIntrument = forms.ChoiceField(label="primaryInstrument", choices=INTRUMENT_CHOICES)
# radio tempo
from django.db import models
# Create your models here.
class Profile(models.Model):
#user = models.OneToOneField(User)
CHOICES=[(1, "empty"), (2, "major"), (3, "minor")]
#scalechoice = models.IntegerField(choices=CHOICES)
<html>
<head>
{% load static %}
<title>Fantasmix | Generate</title>
<link rel="icon" href="CaptureX.png">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="{% static 'css/musicgeneratestyle.css' %}">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
</head>
<script src='http://www.midijs.net/lib/midi.js'></script>
<style>
body {
background-image: url( "{% static 'images/hpwallpaper.jpg' %}" );
background-repeat: no-repeat;
background-size: 5000px;
animation: breath 30s linear infinite;
}
</style>
<body>
<ul>
<li><img src="{% static 'images/CaptureX.PNG' %}" class = "logo"></li>
<li><a href="/home/">Home</a></li>
<li><a href="/home/about/">About Project</a></li>
<li><a href="/home/generate/">Generate Music</a></li>
<li><a href="/login/">Login</a></li>
</ul>
<br>
<div class = "container-fluid">
<h1 class="animated fadeInUp">Generate Music</h1>
<hr>
<div class = "container">
<div class="col-lg-6">
<h2 class="animated fadeInUp">Length <i class="material-icons" style ="font-size: 30px;" href="#" data-toggle="popover" title="What is length?" data-content="Length in this context refers to how long you would like the song you produce to be. Click the respective radio button below to your preferred length!">help</i></h2>
<label class="selector" style = "font-weight: normal;">Short
<input type="radio" checked="checked" name="radio">
<span class="checkmark"></span>
</label>
<label class="selector" style = "font-weight: normal;">Mid
<input type="radio" name="radio">
<span class="checkmark"></span>
</label>
<label class="selector" style = "font-weight: normal;">Long
<input type="radio" name="radio">
<span class="checkmark"></span>
</label>
</div>
<div class="col-lg-6">
<h2 class="animated fadeInUp">Tempo <i class="material-icons" style ="font-size: 30px;" href="#" data-toggle="popover" title="What is tempo?" data-content="Tempo is the speed at which your music will be played. Click the respective radio button to your preferred tempo!">help</i></h2>
<label class="selector" style = "font-weight: normal;">Slow
<input type="radio" checked="checked" name="radio-alt">
<span class="checkmark"></span>
</label>
<label class="selector" style = "font-weight: normal;">Mid
<input type="radio" name="radio-alt">
<span class="checkmark"></span>
</label>
<label class="selector" style = "font-weight: normal;">Fast
<input type="radio" name="radio-alt">
<span class="checkmark"></span>
</label>
<label class="selector" style = "font-weight: normal;">Faster
<input type="radio" name="radio-alt">
<span class="checkmark"></span>
</label>
</div>
</div>
<!-- Django Python added code-->
<div class = "container">
<div class="col-lg-6">
<h2 class="animated fadeInUp">Instruments <i class="material-icons" style ="font-size: 30px;" href="#" data-toggle="popover" title="How does choosing an instrument work?" data-content="Instruments will define what kind of music you are hearing. The main melody will be played by the primary instrument selected below. The secondary instrument will supply supporting sounds. Below you can select a primary and secondary instrument using the dropdown menus.">help</i></h2>
<label style = "font-weight: normal;">Primary Instrument:</label>
<select class="form-control" name="primaryInstrument">
<option value="empty">Pick an instrument</option>
<option value="piano">Piano</option>
<option value="guitar">Guitar</option>
<option value="synth">Synth</option>
<option value="violin">Violin</option>
<option value="banjo">Banjo</option>
</select>
<br>
<label for="secondaryInstrument" style = "font-weight: normal;">Secondary Instrument:</label>
<select class="form-control"id="secondaryInstrument">
<option value="empty">Pick an instrument</option>
<option value="none">None</option>
<option value="piano">Piano</option>
<option value="guitar">Guitar</option>
<option value="synth">Synth</option>
<option value="violin">Violin</option>
<option value="banjo">Banjo</option>
</select>
</div>
<div class="col-lg-6">
<h2 class="animated fadeInUp">Scale <i class="material-icons" style ="font-size: 30px;" href="#" data-toggle="popover" title="What is scale?" data-content="Music scale is an organized sequence of notes. Depending what scale you choose, the pitch of your music will change!">help</i></h2>
<label style="font-weight: normal;">Scale:</label>
<select class="form-control" name="scalechoice">
<!--<option value="empty">Pick an scale</option>-->
<option value="major">Major</option>
<option value="minor">Minor</option>
</select>
</div>
</div>
<br><br>
<!-- Django Python added code-->
<form action="/home/generateMusic/" method="createMusic">
{% csrf_token %}
Testing Code<br>
<label>Song name: </label>
<input id="songName" type="text" name="songName" value="name">
<input id="tempo" type="text" name="tempo" value="mid">
<input id="length" type="text" name="length" value="short">
<input id="instrument" type="text" name="instrument" value="guitar">
<input id="scale" type="text" name="scale" value="major">
<div class = "container">
<!--<div class="col-lg-6">
<h2 class="animated fadeInUp">Instruments <i class="material-icons" style ="font-size: 30px;" href="#" data-toggle="popover" title="How does choosing an instrument work?" data-content="Instruments will define what kind of music you are hearing. The main melody will be played by the primary instrument selected below. The secondary instrument will supply supporting sounds. Below you can select a primary and secondary instrument using the dropdown menus.">help</i></h2>
<label name="primaryInstrument" style="font-weight: normal;">Primary Instrument:</label>
<select class="form-control" name="primaryInstrument">
<option value="piano">Piano</option>
<option value="guitar">Guitar</option>
<option value="synth">Synth</option>
<option value="violin">Violin</option>
<option value="banjo">Banjo</option>
</select>
</div>-->
<div class="col-lg-6">
<h2 class="animated fadeInUp">Scale <i class="material-icons" style ="font-size: 30px;" href="#" data-toggle="popover" title="What is scale?" data-content="Music scale is an organized sequence of notes. Depending what scale you choose, the pitch of your music will change!">help</i></h2>
<label name="scalechoice" style="font-weight: normal;">Scale:</label>
<select class="form-control" name="scalechoice">
<option value="major">Major</option>
<option value="minor">Minor</option>
</select>
</div>
</div>
{% if done %} <p> {{done}} </p> {% endif %}
<button type="submit" class="btn btn-outline-success btn-block" id ="generbutt">Generate!</button>
<a href="#" onClick="MIDIjs.play('{% static 'songs/hello.mid' %}');">Play hello.mid</a>
<a href="#" onClick="MIDIjs.stop();">Stop MIDI Playback</a>
</form>
<!-- Django Python added code-->
</div>
</body>
<script>
$(document).ready(function(){
$('[data-toggle="popover"]').popover();
});
</script>
</html>
......@@ -32,7 +32,6 @@ config = {
'messagingSenderId': "1037380528537",
'appId': "1:1037380528537:web:fd0a617620233116"
}
firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
......@@ -78,31 +77,31 @@ def postsign(request):
def generateMusic(request):
# submitbutton = request.POST.get("submit")
instrument = ''
length = ''
songName = 'not working'
songName = ''
tempo=''
# if request.method == 'createMusic':
# instrument = request.POST.get("intrument")
# length = request.POST.get("length")
# tempo = request.POST.get("tempo")
scale=''
scalechoice='not working'
#primaryInstrument=''
form = NameForm(request.GET)
if form.is_valid():
# songName = form['songName'].value()
songName = form.cleaned_data['songName']
#tempo = form.cleaned_data['tempo']
#length = form.cleaned_data['length']
#instrument = form.cleaned_data['intrument']
tempo = form.cleaned_data['tempo']
length = form.cleaned_data['length']
instrument = form.cleaned_data['instrument']
scale = form.cleaned_data['scale']
scalechoice = form.cleaned_data['scalechoice']
#primaryInstrument = form.cleaned_data['primaryIntrument']
# runs midiClass.py file and outputs file into django_project folder
# with the manage.py file
test = midi("mid", "major", "guitar", "mid", songName)
test.runProgram()
message = "program ran! the .midi is in the first django_project folder -----> "+songName
test = midi("mid", scale, instrument, "mid", songName)
# test.runProgram()
# message = "program ran! the .midi is in the first django_project folder -----> " + songName + " " + tempo + " " + length + " " + instrument
message = scalechoice
return render(request, "musicgenerate.html", {"done": message})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment