Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
update main.py to consider the AudioWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
MGTheTrain committed Apr 17, 2024
1 parent 94b10bc commit 4adeb4a
Showing 1 changed file with 41 additions and 19 deletions.
60 changes: 41 additions & 19 deletions bindings/python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,60 @@

import argparse
import os

from core_wrapper import CoreWrapper
from audio_wrapper import AudioWrapper

def main(path, wrapper_type):
abs_path = os.path.realpath(path)

if wrapper_type == 'core':
core_wr = CoreWrapper(abs_path)

def main(path):
abs_path=os.path.realpath(path)
wrapper = CoreWrapper(abs_path)
result_add = core_wr.add(10, 5)
print("Addition result:", result_add)

result_add = wrapper.add(10, 5)
print("Addition result:", result_add)
result_subtract = core_wr.subtract(10, 5)
print("Subtraction result:", result_subtract)

result_subtract = wrapper.subtract(10, 5)
print("Subtraction result:", result_subtract)
result_multiply = core_wr.multiply(10, 5)
print("Multiplication result:", result_multiply)

result_multiply = wrapper.multiply(10, 5)
print("Multiplication result:", result_multiply)
result_divide = core_wr.divide(10.0, 2.0)
print("Division result:", result_divide)

result_divide = wrapper.divide(10.0, 2.0)
print("Division result:", result_divide)
radius = 5.0

radius = 5.0
area = core_wr.get_circle_area(radius)
print("Circle area:", area)

area = wrapper.get_circle_area(radius)
print("Circle area:", area)
circumference = core_wr.get_circle_circumference(radius)
print("Circle circumference:", circumference)
elif wrapper_type == 'audio':
audio_wr = AudioWrapper()

audio_file_path = "assets/mp3/file_example_MP3_700KB.mp3"
if not audio_wr.load_audio_file(audio_file_path):
print("Failed to load audio file:", audio_file_path)
return

if not audio_wr.start_playback():
print("Failed to start playback.")
return

circumference = wrapper.get_circle_circumference(radius)
print("Circle circumference:", circumference)
audio_wr.close_audio_file()
else:
print("Unsupported wrapper type provided.")

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--path', type=str, help='Path to the core wrapper library')
parser.add_argument('--path', type=str, help='Path to the wrapper library')
parser.add_argument('--wrapper', type=str, choices=['core', 'audio'], help='Select wrapper type: core or audio')
args = parser.parse_args()

if not args.path:
parser.error('Please provide the path to the core wrapper library using --path')
parser.error('Please provide the path to the wrapper library using --path')
if not args.wrapper:
parser.error('Please select the wrapper type using --wrapper')

main(args.path)
main(args.path, args.wrapper)

0 comments on commit 4adeb4a

Please sign in to comment.